$scope var not propagating in child
In a list of items, clicking an item opens up an input field using
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>
However, when clicking on save, setting showInput=false the form is not
hiding:
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;
}
}]);
I suspect this is a parent / child scope issue. Can anyone point out how
to make this work?
Fiddle: http://jsfiddle.net/supercobra/PUZzZ/
No comments:
Post a Comment