角度错误将“*”分配给范围

时间:2016-03-29 03:43:56

标签: javascript angularjs

Mi问题是这个,我在范围内声明了var:

$scope.submit={
 next:"",
 formparams:"",
 value:""

};

在mi html中我有:

     <div>
   <div ng-repeat="opcion in menu.opciones"><label> Opcion: </label>
     <input id="{{opcion.opcion}}" type="radio" name=grupo
      value="{{opcion.Submit}}+{{opcion.opcion}}" ng-model="submit.next"
      ng-change="submit.value={{opcion.opcion}}" ng-required="true"required> {{opcion.opcion}}                          
    </input>
</div></div>

选项数组包含{1,2,3,*}

之类的内容

当我选择每个数字选项工作正常,但当我在浏览器的控制台中选择“*”时出现下一个错误:

    angular.js:9419 TypeError: a is not a function
at OPERATORS.* (http://192.168.0.3:8080/MobilTest/lib/angular.js:9515:44)
at http://192.168.0.3:8080/MobilTest/lib/angular.js:10041:35
at Scope.$eval (http://192.168.0.3:8080/MobilTest/lib/angular.js:11961:28)
at http://192.168.0.3:8080/MobilTest/lib/angular.js:16943:13
at http://192.168.0.3:8080/MobilTest/lib/angular.js:16784:11
at Array.forEach (native)
at forEach (http://192.168.0.3:8080/MobilTest/lib/angular.js:303:11)
at $setViewValue (http://192.168.0.3:8080/MobilTest/lib/angular.js:16782:7)
at http://192.168.0.3:8080/MobilTest/lib/angular.js:16284:14
at Scope.$eval (http://192.168.0.3:8080/MobilTest/lib/angular.js:11961:28)(anonymous function) @ angular.js:9419(anonymous function) @ angular.js:6843(anonymous function) @ angular.js:16786forEach @ angular.js:303$setViewValue @ angular.js:16782(anonymous function) @ angular.js:16284Scope.$eval @ angular.js:11961Scope.$apply @ angular.js:12061(anonymous function) @ angular.js:16283(anonymous function) @ angular.js:2613forEach @ angular.js:310eventHandler @ angular.js:2612

var是空的。

先谢谢。

1 个答案:

答案 0 :(得分:0)

{1,2,3,*} *与表达式+中的{{opcion.Submit}}+{{opcion.opcion}}结合使用时,会被评估为运算符。只需将其更改为类似{1,2,3,'*'}的字符即可。