导轨+ angularjs载荷值插入编辑文本框 [英] rails + angularjs loading values into textfields on edit

查看:129
本文介绍了导轨+ angularjs载荷值插入编辑文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用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.

又见<一个href=\"http://stackoverflow.com/questions/10610282/angularjs-value-attribute-on-an-input-text-box-is-ignored-when-there-is-a-ng-m\">AngularJS - 当使用NG-模型上输入文本框Value属性被忽略

这篇关于导轨+ angularjs载荷值插入编辑文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆