This is a draft cheat sheet. It is a work in progress and is not finished yet.
Modules
Define |
var mod = angular.module('name', []); Dependency array is not an optional parameter but can be empty. |
Retrieve |
var mod = angular.module('name');
|
Config |
var mod = angular.module('name', [], function config() { });
- OR - mod.config(function config() { }); Provider injectables only. |
Run |
mod.run(function run() { }); Standard injectables only. |
App Module Usage |
<body ng-app="name"></body>
|
Directives
Define |
mod.directive('myDirective', function(...) { return { restrict: 'AEC', // some combination of the three scope: {}, // isolate scope template: 'some html', templateUrl: 'path/to/template', replace: true OR false, transclue: true OR false, require: 'directiveName', link: function(scope, elem, attr, controller, transcludeFn) { } }; });
|
Retrieve |
mod.directive('myDirective');
|
|
|
Controllers
Define |
mod.controller('name', function name() { }); Dependencies injected by named parameter. |
Retrieve |
var ctrl = mod.controller('name');
|
Array Syntax |
mod.controller('name', ['depName', function name(depName) { }]);
|
Controller as Usage |
<div ng-controller="name as vm"></div>
|
Standard Usage |
<div ng-controller="name"></div>
|
|