Angular1Liners's profile picture. AngularJS tips in under 140 characters.

AngularJS Tips

@Angular1Liners

AngularJS tips in under 140 characters.

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.


AngularJS Tips 已轉發

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


Before a route changes, Angular will broadcast the $routeChangeStart event. #angularjs


Because directives can require the controller of another directive, ctrls are a great place to put actions used in more than 1 directive.


In AngularJS, if you're debating on using a directive, use a directive. #angularjs


In your directive, "scope: {}" is isolated and "scope: true" is inherited. #angularjs


The $apply method will directly call the $digest loop. #angularjs #javascript.


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


Loading...

Something went wrong.


Something went wrong.