0
$scope.foo = {'name': 'user_name', 'bindTo': 'user.name'};
然後在HTML:
<label for="user_name">User Name</label>
<input name="{{foo.name}}" type="text" class="form-control" ng-model="{{foo.bindTo}}"/>
這拋出:
Syntax Error: Token 'foo.bindTo' is unexpected, expecting [:] at column 3 of the expression [{{foo.bindTo}}] starting at [foo.bindTo}}]
有一種方法爲了達成這個?
看看它http://stackoverflow.com/questions/15964278/angularjs-bind-ng-model -to-A-可變其名稱管理被存儲-內部-另一個-VARI –