AngularJS Tips
@Angular1Liners
AngularJS tips in under 140 characters.
You might like
Interested in learning @reactjs? Check out ReactWeek.com. A week long workshop focused on learning React taught by @ryanflorence.
With the exception of isolate scopes, all scopes are created with prototypal inheritance, meaning they have access to their parent scopes.
My blog post on the differences between Factories, Services, and Providers in AngularJS. goo.gl/NozeGf
The link function is invoked AFTER the compiled template, so do DOM manipulation, event listeners, and data change 'watchers' here.
In Angular, the default headers sent for every request live in in the $httpProvider.defaults.headers.common object. #angularjs
Although tempting, try to not use $watch in a controller. It makes it difficult to test. #angularjs
The "then" method returns a new promise after the initial promise is resolved. This gives you the ability to chain your promises #angularjs
Because directives can require the controller of another directive, ctrls are a great place to put actions used in more than 1 directive.
The main use case for Isolate Scopes are for reusable widgets that can be shared & used in unexpected contexts wo/ polluting other scopes.
When you handle an event manually, use a 3rd party framework, or call setTimeout, you'll want to use $apply to rerun the digest loop.
In AngularJS, after a template has been fetched (using AJAX), Angular caches it in the $templateCache service.
Dirty checking checks whether a value has changed that hasn't yet been synchronized across the application. #angularjs #javascript
With a directive use an Ele. if you encapsulate a self-contained piece of functionality. Use an Attr when decorating existing element.
The $evalAsync method is a way to schedule running expressions on the current scope at some time in the future.
A directive is just a function that can run on a particular DOM element. The function is expected to provide extra functionality on an elem.
$scope.$apply() is a way to gain access to the Angular context from outside of it. #angularjs #JavaScript
United States Trends
- 1. New York 31.6K posts
- 2. New York 31.6K posts
- 3. Good Wednesday 25.5K posts
- 4. #wednesdaymotivation 1,828 posts
- 5. #questpit 11.9K posts
- 6. Virginia 591K posts
- 7. Hump Day 10.4K posts
- 8. Van Jones 4,161 posts
- 9. 5th of November 17.6K posts
- 10. #ChavismoEnVanguardia 1,093 posts
- 11. #Wednesdayvibe 1,394 posts
- 12. Talus 21.7K posts
- 13. Enhanced 11.4K posts
- 14. Alastor 31.2K posts
- 15. #WednesdayWisdom N/A
- 16. The GOP 266K posts
- 17. Nueva York 123K posts
- 18. AND SO IT BEGINS 18.7K posts
- 19. Socialism 102K posts
- 20. But the Lord 9,880 posts
Something went wrong.
Something went wrong.