在项目列表中,单击项目会打开一个使用 的输入字段ng-show="showInput=true"
。
<div ng-app="myApp" ng-controller="Ctrl">
<li ng-click="showInput=true" ng-repeat="label in labels">{{label}} - ---> show input = {{showInput}}
<form ng-show="showInput" >
<input type=text value={{label}}><button ng-click="saveDate()">save</button>
</form>
</li>
</div>
但是,单击 时save
,设置showInput=false
表单不会隐藏:
angular.module('myApp', [])
.controller('Ctrl', ['$scope', function($scope) {
$scope.labels=["click a", "click b", "click c", "click d", "click e"];
$scope.showInput = false;
$scope.saveData = function(){
$scope.showInput = false;
}
}]);
我怀疑这是父/子范围问题。谁能指出如何使这项工作?
小提琴:http: //jsfiddle.net/supercobra/PUZzZ/