http://terussell85.github.io/blog/2013/12/23/the-angularjs-promise-anti-pattern-that-makes-me-cry/
[cheatsheet] Angular 1.3.9
Resolve Resources Centrally
Expressions
Component Based Directives
1 ;
2 (function() {
3 'use strict';
4
5 angular.module('testModule', [])
6
7 .directive('testDirective', [
8 function(EccAPI) {
9 return {
10 restrict: 'E',
11 scope: {
12 test: '@'
13 },
14 templateUrl: '/component-tpl.html',
15 bindToController: true,
16 controllerAs: 'testdir',
17 controller: function($scope, $element, $attrs, $transclude) {
18 this.clickBtn = function() {
19 console.log($scope);
20 console.log('woah');
21 }
22 },
23 link: function($scope, $element, $attrs) {
24
25 }
26 }
27 }
28 ])
29 }());
Factory Patterns
1 myApp.factory('myFactory', ['$rootScope', function ($rootScope) {
2 $rootScope.$emit("myEvent", myEventParams);
3 }]);
ng-repeat
ng-repeat that will display loading or if empty set of data.
1 <ul>
2 <li ng-if="outstanding == undefined">
3 <i class="fa fa-refresh fa-spin"></i> Loading...
4 </li>
5 <li ng-if="outstanding.items.length === 0">
6 Nothing is Available...
7 </li>
8 <li ng-if="item.type != 'script'" ng-repeat="item in outstanding.items">
9 <img placeholdit width="60" height="60" size="60x60" ng-src="item.url">
10 <div class="item-meta">
11 <h4></h4>
12 <span class="description">
13 <p></p>
14 </span>
15 </div>
16 <div class="actions">
17 <button ng-click="download(item, outstanding.hashToken)">
18 <i class="fa fa-cloud-download"></i> Button Click
19 </button>
20 </div>
21 </li>
22 </ul>