【发布时间】:2012-08-10 08:10:39
【问题描述】:
这是我的 HTML:
<div ng-app="angularApp">
<div ng-controller="testCtrl">
testKey = {{testKey}}<br />
Test 1: <input type="text" ng-model="test.myKey" />{{test[testKey]}}<br />
Test 2: <input type="text" ng-model="test[testKey]" />{{test[testKey]}}
</div>
</div>
这里是js:
angular.module('angularApp', []);
function testCtrl($scope)
{
$scope.testKey = "myKey";
}
我设置和示例here
为什么测试 1 有效但测试 2 无效? ng-model 指令中是否不允许使用“[”?
【问题讨论】:
标签: binding controller scope angularjs