Tuesday, January 6, 2015

Angular.js style guide: using an activate() method inside your controller

There are lots of opinions about how to write good Angular code. One of the best style guides out there is the one created by John Papa available at https://github.com/johnpapa/angularjs-styleguide.

It contains a large list of great tips about naming guidelines, application structure, testing, exception handling, and so on…

One advice that I started to implement recently is the usage of ‘Controller Activation Promises’. It solves the problem where you have your start-up logic scattered around across the controller. It places all start-up logic in a consistent place.

How do you this? Simple, create an activate() function and put all your start-up logic inside:

21 comments:

Gezerk said...

Thanks very much for the introduction to the Angular style guide. I have been using Angular and I was not at all happy with how I was doing it. The style guide was exatcly the guidance I needed it. I would never have found it without your post!

Raju Kumar said...

I am extremely impressed with your writing skills and also with the layout on your blog
Angularjs Training In Hyderabad

Aishu said...

Very good explanation.

AngularJs Training
AngularJs Training in Chennai

osvaldo anderson said...

AngularJS is an open-source JavaScript framework that assists with running SPA.
AngularJS Training

for IT the said...

Angular 2 Training in Chennai angular2 Training in Chennai | angular2 Training in Chennai


Angular 2 Training in Chennai AngularJS Training in Chennai AngularJS Training in Chennai Angularjs Training Angularjs Training AngularJS Training in Chennai AngularJS Training in Chennai

Adlearning Technologies said...

Thank You for sharing your article. I like it. We provide TIBCO Online Training in Hyderabad.

Philip Nielsen said...

Is this different from $onInit for Angular 1.5?

vinayangadi said...
This comment has been removed by a blog administrator.
InduPriya said...

Really Nice blog about AngularJS. Thank You.....

Rakesh said...

nice information
SoftwareTraining

Gopi Krishna said...

AngularJS is a toolset for building the framework most suited to your application development. It is fully extensible and works well with other libraries. Every feature can be modified or replaced to suit your unique development workflow and feature needs. Read on to find out how.

AngularJS Training in Chennai
AngularJS Training Institute in Chennai

AngularJS Certification Training in Chennai

Sujit kUmar said...

nice post for sharing angularjs article. its really helpful for me.keep sharing on updated angularjs tutorials????????????????

Thank you

Anonymous said...

On line 13 is the code:

return vm.avengers;

I am struggling to understand --- who is this being returned to, and why?

Hope you can help

Thanks
Brian

Albert Smith said...

Wow, although I landed on this page accidentally while I was looking for reference materials for Thesis Finishing, I have learned a lot about the art of simplicity and I am going to implement the outlined guidelines. Thanks a lot for sharing this blog post with us. I have found it to be very useful.

Shreeja K said...

Informative article, just what I was looking for.seo services chennai

vigneswaran said...

The ASP.NET Validation controls to imports aspects of new web application creation.The user input into the able check that ASP.NET validation control towards easy-to-use powerful validates way to check it displays error message to a user.
If want become a learn for Big Data Hadoop to be reach that,
Hadoop Training in Chennai | Hadoop Training | Hadoop Training Institute in Chennai with Placement

Angularjs training said...

Hi, You have shared post is informative and easy to understand AngularJS for beginners. Thanks for your effort.

angularjs certification course
angularjs course fee in chennai
angularjs training in chennai

Innozant Technologies said...

Hii Everyone Innozant Provided Angular JS is also one of the best course to learn in the present scenario. It gives us a best opportunity to find a good job. More Information Visit Here:- https://goo.gl/PUUyZd

Hope Vignesh said...

Awesome information. I expect more tutorials about Angulr Js

Rajesh Developer said...

It's very nice blog. I'm so happy to gain some knowledge from here. Thank you for valuable
information on
AngularJS Training in Chennai.
Hoping to get more info...

Innozant Technologies said...

The blog you wrote is the sign of a good writer. I am highly impressed with this blog, due to which the information here seems very beneficial to me.You are a very good writer and I am excited to read your new blog..https://goo.gl/LkRozB