Reputation: 15303
I am adding my datas as one time binding. and as well I am trying to updating the list of data too.
for trigger a update, I am trying to toggling
the ng-show
directive. But I am not getting the expected result. Might be I required to do all CURD
operations with one time bindng
- any one show the issue what i keep here or the correct way to do?
here is my code :
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope,$timeout) {
$scope.visible = true;
$scope.name = 'World';
$scope.data = [
{"name":"name1","city":"city1"},
{"name":"name2","city":"city2"},
{"name":"name3","city":"city3"}
]
$scope.addItem = function( item ){
$scope.visible = false;
var value = Math.ceil(Math.random()*10+1);
$scope.data.push({
name:"name"+value,
city:"city"+value
});
console.log( $scope.data );
$timeout(function() {
$scope.visible = true;
});
}
});
Upvotes: 0
Views: 38
Reputation: 51
Use ng-if with your ng-show. While ng-if detach dom element when false, ng-show just hide the element.
Upvotes: 2