I'm trying to manipulate the value of ng-model in ionic. It works fine in name attribute.
我试图在离子中操纵ng-model的值。它在name属性中工作正常。
<input type="radio" name="svData.q{{option.qoQID}}" value="{{option.qoID}}">
the output was right as expected:
输出是正确的预期:
<input type="radio" name="svData.q1" value="1">
I'm trying to use ng-model attribute instead of name. I've tried:
我正在尝试使用ng-model属性而不是名称。我试过了:
<input type="radio" ng-model="svData.q{{option.qoQID}}" value="{{option.qoID}}">
and it does not work.
它不起作用。
Error: [$parse:syntax] Syntax Error: Token '{' is an unexpected token
错误:[$ parse:syntax]语法错误:令牌'{'是一个意外的令牌
was produced. I was expecting the output to be like:
制作完成了。我期待输出如下:
<input type="radio" ng-model="svData.q1" value="1">
any solution or suggestion?
任何解决方案或建议?
1 个解决方案
#1
I believe the ngModel directive will only bind the value
attribute of the input to a property on the scope. If you intend to bind the name
attribute then you will have to use the ngBind syntax {{ }}
the way you did in the beginning
我相信ngModel指令只会将输入的value属性绑定到作用域上的属性。如果您打算绑定name属性,那么您将不得不像开始时那样使用ngBind语法{{}}
#1
I believe the ngModel directive will only bind the value
attribute of the input to a property on the scope. If you intend to bind the name
attribute then you will have to use the ngBind syntax {{ }}
the way you did in the beginning
我相信ngModel指令只会将输入的value属性绑定到作用域上的属性。如果您打算绑定name属性,那么您将不得不像开始时那样使用ngBind语法{{}}