Question

When using AngularJS with a rails application I've hit a problem when editing records the value of the text fields is set to blank. Is there a way to tell AngularJS to use the values rails gives the form elements as the initial value?

I've put together a JSFiddle to demonstrate the issue I'm having:

http://jsfiddle.net/YUza7/15/

Was it helpful?

Solution

As you already stated in your answer, you can use ng-init.

A more "Angular way" of doing it would be to modify your $scope/data model and not use the value parameter on your form elements.

See also AngularJS - Value attribute on an input text box is ignored when there is a ng-model used?

OTHER TIPS

Used ng-init directive as it loads initial values before running any of your code.

http://jsfiddle.net/YUza7/17/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top