【发布时间】:2013-08-21 08:00:09
【问题描述】:
我无法修改由 ng-repeat 生成的文本框。由于父/子范围,它也有点复杂。
脚本:
function ConfigController($scope)
{
$scope.config = {"key1":["a","b","c"]};
}
function SettingController($scope)
{
var configKey = null;
function update() {
$scope.items = $scope.config[configKey];
}
$scope.init = function(key) {
configKey = key;
update();
};
$scope.$watch('config', update, true);
}
标记:
<div ng-app ng-controller="ConfigController">
Config: {{config}}
<div ng-controller="SettingController" ng-init="init('key1')">
Items: {{items}}
<div ng-repeat="item in items">
<input ng-model="item" type="text"/>
</div>
</div>
</div>
【问题讨论】:
标签: javascript html angularjs