See more:http://toddmotto.com/opinionated-angular-js-styleguide-for-teams/ /** * Created by Answer1215 on 1/13/2015. */ /** * Controller(s) * */ function AppController($rootScope, $location) { var appCtrl = this; $rootScope.$on('$routeChangeError', f…
ControllerAs: Use thecontrollerAs syntax always as it aids in nested scoping and controller instance reference. Bad: <div ng-controller="MainCtrl"> {{ someObject }} </div> Good: <div ng-controller="MainCtrl as main">…
Annotation Order: It's considered good practice to dependency inject Angular's providers in before our own custom ones. Bad: // randomly ordered dependencies function SomeCtrl (MyService, $scope, AnotherService, $rootScope) { } Good: // ordered Angul…
Module definitions Angular modules can be declared in various ways, either stored in a variable or using the getter syntax. Use the getter syntax at all times (angular recommended). Bad: var app = angular.module('app', []); app.controller(); app.fact…
After reading Google's AngularJS guidelines, I felt they were a little too incomplete and also guided towards using the Closure library. They also state "We don't think this makes sense for all projects that use AngularJS, and we'd love to see our co…
What's promise Angular’s event system provides a lot of power to our Angular apps. One of the most powerful features that it enables is automatic resolution of promises. Promises are a method of resolving a value or not in an asynchronous manner. Pro…