在指令NG-模型问题 [英] ng-model problems in a directive
问题描述
我想写我的第一个不平凡的指令时遇到的问题。
I am trying to write my first non-trivial directive and am having problems.
我所试图做的是类似 http://plnkr.co/nYSBnm
此工作按预期除了两个输入都使用相同的字段。当我尝试,让他们通过将使用意域,
This works as intended apart from the two inputs are using the same field. When I try and get them to use the intended fields, by putting
ng-model="record.{{field.name}}"
在属性的formInput更换NG模型=record.name我得到一个错误
in the formInput attributes to replace ng-model="record.name" I get an error
Error: Syntax Error: Token '{' is an unexpected token at column 8 of the expression [record.{{field.name}}] starting at [{{field.name}}].
对于什么是值得的普拉克在 http://plnkr.co/O2uosO27khbcxZEeEb6V
我看过各种各样的有点类似的问题在这里堆栈溢出,并至今未能得到任何工作。
I have looked at various somewhat similar questions on here and stack overflow and so far failed to get anything to work.
我将不胜感激任何光线任何人都可以在它扔。
I would be grateful for any light anyone can throw on it.
标记
推荐答案
我还要求对AngularJS组(我这里张贴了一天左右后沉默在那里)这个问题。然后我接到了帕维尔·科兹洛夫斯基指出谁的响应是
I had also asked this question on the AngularJS group (I posted here after a day or so of silence on there). Then I got a response from Pawel Kozlowski who pointed out that
ng-model="record[field.name]"
的那种开始工作,因为他所说的那样。有一个普拉克这里。
不知道他是什么意思被他的评价,但是当我把在一个真正的页面,点击刷新我得到了场的两个副本(除非我清空缓存),但他肯定解决了所述问题。
Not sure what he meant by his comment but when I put that in a real page and hit refresh I get two copies of the fields (unless I clear the cache), but he certainly solved the stated problem.
这篇关于在指令NG-模型问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!