2015年11月11日 星期三

angular js Dependency injection

https://www.airpair.com/angularjs/posts/top-10-mistakes-angularjs-developers-make


Dependency injection is one of AngularJS's best patterns. It makes testing much simpler

var app = angular.module('app',[]); app.controller('MainCtrl', function($scope, $timeout){ $timeout(function(){ console.log($scope); }, 1000); });
Here, it's very clear that MainCtrl depends on $scope and $timeout.



沒有留言:

張貼留言