AngularJS: Setting a variable in a ng-repeat generated scope -
how access set of scopes generated ng-repeat?
i suppose @ heart of fact don't understand quite how relationship works between a) collection of objects pass ng-repeat directive , b) collection of scopes generates. can play around (a), ng-repeat scope watches , picks up, how set variables on scope (b)?
my use case have set of elements repeating using ng-repeat, each of has edit view gets toggled using ng-show/ng-hide; state each element held in variable in local scope. want able trigger ng-show on particular element, want trigger called outside ng-repeat, need able access local scope variable.
can point me in right direction (or tell me if i'm barking wrong tree)?
thanks
update: link below helpful thankful. in end created directive each of repeating elements, , used directive's link function add scope collection on root scope.
when working within hierarchy of scopes find useful dispatch events $emit , $broadcast. $emit dispatches event upwards child scopes can notify parent scopes of particular event. $broadcast other way round.
alternatively, child scopes have access parent scope properties trigger changes using $watch on particular property in parent scope.
update: accessing child scopes, may turn useful : get child scopes in angularjs given parent scope
Comments
Post a Comment