Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Compiling material directives on the fly: md-input-has-value attribute not set #3017

Closed
warpdesign opened this issue May 28, 2015 · 4 comments
Assignees
Milestone

Comments

@warpdesign
Copy link

I'm trying to dynamically compile material directives. It works, but for some reason, doesn't get the md-input-has-value attribute set, even though my inputs have a value set.

Maybe I'm doing something wrong ?

Here is an example:

$('<div id="foo"><md-input-container><label for="myInput">Plop</label><input id="myInput" name="myInput" value="48" type="text"/></md-input-container></div>').appendTo('body');

scope = $rootScope.$new();
$compile($('#foo').contents())(scope);

My input correctly gets the material styles, but since the md-input-has-value attribute isn't set, the value isn't displayed unless the input gets the focus.

Maybe I am missing something ?

@warpdesign
Copy link
Author

I'll answer to my own question: it seems it will only work if the input is binded to some variable (ie: input has ng-model set). Is it intended ?

@typeofweb
Copy link

I think this is a bug. 👍

@ThomasBurleson ThomasBurleson added this to the 0.11.0 milestone Jun 29, 2015
@ThomasBurleson ThomasBurleson self-assigned this Jun 29, 2015
@Splaktar
Copy link
Member

Splaktar commented Jul 5, 2015

@warpdesign This looks very similar to #2162 which effects both IE and Firefox. Which browser were you seeing this problem in? Does #3582 fix it for you?

@ThomasBurleson ThomasBurleson modified the milestones: 0.11.0, REVISIT Jul 31, 2015
@ThomasBurleson ThomasBurleson modified the milestones: REVISIT, Backlog Aug 10, 2015
@ThomasBurleson ThomasBurleson modified the milestones: post-1.0 , Backlog Sep 4, 2015
@Anthropic
Copy link

@ThomasBurleson this is more than a low priority to my project, I'm adding an md-input-container with an input inside to a dynamically generated form and while the data then works I've had to add the following to get it to detect the init state:

ng-class="{'md-input-has-value': model.value}"

I'd prefer a solution more long term prior to releasing the Material version of the form generator I'm working on to end users.

@ThomasBurleson ThomasBurleson modified the milestones: post-1.0 , Backlog Jan 5, 2016
@ThomasBurleson ThomasBurleson modified the milestones: Backlog, Deprecated Apr 20, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants