betsol / angular-input-date

AngularJS directive to enable support for date input type
38 stars 19 forks source link

How to set initial value? #5

Closed fidoboy closed 9 years ago

fidoboy commented 10 years ago

ng-value="field.date" doesn't work. How can i set the value for this input?

slavafomin commented 10 years ago

I'm not familiar with ngValue directive. You should probably use ngModel.

slavafomin commented 10 years ago

As stated in the documentation of ngValue, this directive should be used with input[type="radio"] or option elements. ngModel should be sufficient for input[type="date"]. However, I would recommend to switch to the AngularJS 1.3.x which doesn't require this polyfill. Please let me know, if you have further questions.

fidoboy commented 10 years ago

Thanks @slavafomin for answering so fast :) Unfortunately i can't upgrade to 1.3 already and i'm using 1.2.26. Finally i've solved it using hg-model and ng-init in parent DOM element to define the starting value. ngValue doesn't seems to work; well, it works, cause value attribute is being filled and displayed but the directive doesn't seems to be using it.

slavafomin commented 10 years ago

No problem ;) By the way, why can't you set initial value in the controller in JavaScript?

fidoboy commented 10 years ago

Because my data is coming from remote server

slavafomin commented 10 years ago

You can apply data as soon as it loaded to the underlying model in the controller or even better you can inject this data to the controller using resolve (if you are using ng-route). I'm doing this all the time and it works perfectly.

slavafomin commented 9 years ago

I'm closing this issue for now. If you have any further questions feel free to ask them. Cheers!