Monday, December 15, 2014

several points on Angular JS usage

Just things in random order, I've came across last days.



1) Scroll other div to specific place  - http://plnkr.co/edit/lXmUryJIPWiOZZiW1RDW?p=preview
( by default there is a service that working for window element)

2) Syntax with binding once of model properties in templates like {{::myStaticVar}} - does not work by some reason, gives parse error. (Maybe it was removed in one of the versions ??)

3) Working with events: $scope.$broadcast -> goes DOWN, while $scope.$emit -> goes UP in scopes

4) Watch tools, basic - $scope.$watch(‘varName’, callback)
 - also available watchCollection for array of vars (https://docs.angularjs.org/)
 - if you want to access $parent or $root scope, you can use first argument as a function that will return needed scope value (http://stackoverflow.com/)
 - if you need the directive to update dynamically on scope changes - use scope.$watch subscription on vars changes in its link function



6) several dozens of other tips and tricks using Angular JS - http://blog.tomaka17.com/2012/12/random-tricks-when-using-angularjs/

No comments:

Post a Comment