2016-04-04 3 views
1

私は角度に基づいてプロジェクトに取り組んでいます。 ng-repeatで変数を初期化しているときに問題に直面しています.ng-initで変数を初期化してng-modelで使用したいのですが、コンソールで次のエラーが発生しています。すべてのヘルプは、次のng-repeatでng-initを使用して変数に値をバインドする方法はありますか?

ionic.bundle.js:25510 Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 6 of the expression [key={{component.name}}] starting at [{component.name}}]. 
http://errors.angularjs.org/1.4.3/$parse/syntax?p0=%7B&p1=invalid%20key&p2=6&p3=key%3D%7B%7Bcomponent.name%7D%7D&p4=%7Bcomponent.name%7D%7D 
at http://localhost:8100/lib/ionic/js/ionic.bundle.js:13248:12 
at Object.AST.throwError (http://localhost:8100/lib/ionic/js/ionic.bundle.js:26061:11) 
at Object.AST.object (http://localhost:8100/lib/ionic/js/ionic.bundle.js:26048:16) 
at Object.AST.primary (http://localhost:8100/lib/ionic/js/ionic.bundle.js:25956:22) 
at Object.AST.unary (http://localhost:8100/lib/ionic/js/ionic.bundle.js:25944:19) 
at Object.AST.multiplicative (http://localhost:8100/lib/ionic/js/ionic.bundle.js:25931:21) 
at Object.AST.additive (http://localhost:8100/lib/ionic/js/ionic.bundle.js:25922:21) 
at Object.AST.relational (http://localhost:8100/lib/ionic/js/ionic.bundle.js:25913:21) 
at Object.AST.equality (http://localhost:8100/lib/ionic/js/ionic.bundle.js:25904:21) 
at Object.AST.logicalAND (http://localhost:8100/lib/ionic/js/ionic.bundle.js:25896:21) 
at Object.AST.logicalOR (http://localhost:8100/lib/ionic/js/ionic.bundle.js:25888:21) 
at Object.AST.ternary (http://localhost:8100/lib/ionic/js/ionic.bundle.js:25874:21) <div ng-repeat="component in reportTemplate" ng-init="key={{component.name}}" class="inputFieldSection inputFieldTitle" ng-if="component.type == 'text'" data-ng-animate="1"> 

を理解されるであろうあなたは{{}}削除する必要があります私のコードスニペット

<div ng-repeat="component in reportTemplate" ng-init="key={{component.name}}" class="inputFieldSection inputFieldTitle" ng-if="component.type == 'text'"> 
          <label class="item item-input"> 
          <input type="text" name={{component.name}} ng-model=reportTemplateKeyData[key] ng-focus="clearValidation();" max-length="50" required placeholder="{{component.label}}"> 
          </label> 
          <p ng-show="createReportForm[component.name].$error.required">Please Enter {{component.name}}</p> 
        </div> 

答えて

1

です。

ng-init="key=component.name" 
+0

感謝。 –

0

にNG-INITを変更してみてください:動作します.IT ng-init="key=component.name"

関連する問題