angularjs - How to forbideen updating model in Angular JS? -
i have nested controller like:
<div ng-controller="maincontroller"> <div ng-controller="childcontroller"></div> </div> inside child controller there function:
$scope.isstatus = function() { return function(item) { }}; this function used in ng-repeat.
so, problem when modify model of controller maincontroller reload model of childcontroller, means function isstatus() works again , reload model. how fix it?
you can use controlleras syntax avoid this
<div ng-controller="maincontroller main"> <div ng-controller="childcontroller child"> <ul ng-repeat ="item in child.item"> </div> </div> and in js
function childcontroller (){ var vm = this; vm.isstatus = function() { return function(item) { }}; } you can see more infomation in here
https://github.com/johnpapa/angular-styleguide/tree/master/a1#controllers
Comments
Post a Comment