I've encountered an issue trying to bind a value to an input in Angular. I initialized the 'object[component.name]' first and then assigned that value to ng-model. This was necessary because I needed to bind the value from ng-repeat, but it's giving me an error. Below is my code snippet. Any assistance would be greatly appreciated.
<div ng-repeat="component in reportTemplate" class="inputFieldSection inputFieldTitle" ng-if="component.type == 'text'">
<label class="item item-input">
<input type="text" name={{component.name}} ng-init="object[component.name]={{component.name}}" ng-model="object[component.name]" 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>
Console Error Message:
ionic.bundle.js:25510 Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 25 of the expression [object[component.name]={{component.name}}] starting at [{component.name}}].
http://errors.angularjs.org/1.4.3/$parse/syntax?p0=%7B&p1=invalid%20key&p2=…Bcomponent.name%5D%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) <input type="text" name="{{component.name}}" ng-init="object[component.name]={{component.name}}" ng-model="object[component.name]" ng-focus="clearValidation();" max-length="50" required="" placeholder="{{component.label}}" class="ng-pristine ng-untouched ng-valid">