导轨+ angularjs载荷值插入编辑文本框载荷、导轨、文本框、编辑

2023-09-13 04:12:32 作者:爷就愛伱一个

在使用AngularJS与Rails应用程序时,编辑记录的文本字段的值设置为空我已经打了一个问题。有没有办法告诉AngularJS使用的值铁轨给表单元素作为初始值?

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?

我已经把一个的jsfiddle证明我有这个问题:

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

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

推荐答案

正如你在你的答案已经说过,你可以用NG-初始化。

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.

又见AngularJS - 当使用NG-模型上输入文本框Value属性被忽略