Angularjs directive 2 way binding not working + delay issue -


i'm having following problem. have search.js controller uses template results.html. template uses category directive show categories of company products might have (as sidebar). uses multiple product carousel directives show products of each matching company.

in search.js controller define scope variable named filtercategoryid starts @ null. variable bound categories directive product carousel directives. makes me expect change variable in either of directives in search.js controller propagate others using variable. variable used limit display of products of category.

but on product carousel directive, have defined scope method removefiltercategory() sets filtercategoryid null. works within own scope. can see effects. not effect filtercategoryid on categories directive. can tell because use ng-class set active class list item mentioning category id products filtered. changing filtercategoryid on categories directive does propagate product carousel directives. there ng-repeat before product carousel directives...

in essence. variable first defined on scope of controller. if change on categories directive, change gets propagated (after noticeable while) product carousel directives. if change of product carousel items, categories directive not reflect changes. , don't see why. the product carousel uses $watch check filtercategoryid , recalculate rows..

all directives use isolated scope same variable filtercategoryid , use '=' scope value.

what issue?

and secondary if change filtercategoryid on categories directive, takes 5-6sec reflect changes on product carousel directives.

i'm feeling i'm missing here. either have obvious code error seem overlook or i'm missing angular understanding :). in right direction appreciated.

i suggest explicitly telling angularjs register change using $scope.apply( function(){/*change var here*/}); , see docs.

there nice article explaining details of angular's digest cycle: http://jimhoskins.com/2012/12/17/angularjs-and-apply.html

this seems main problem if experiencing delays though suggest ensuring variable filtercategoryid always object, never passed copy, maybe change filter.categoryid etc.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -