2015-10-20 66 views
0

this tutorial,所述控制器:如何定义角流星控制器?

angular.module('socially').controller('PartiesListCtrl', function ($scope, $meteor) { 
    $scope.parties = $meteor.collection(Parties); 
}); 

another tutorial,所述控制器:

angular.module('simple-todos').controller('TodosListCtrl', ['$scope', '$meteor', 
    function ($scope, $meteor) { 

    $scope.tasks = $meteor.collection(Tasks); 
}]); 

的是上述相同?

回答

1

这是两种不同的符号。两者都可以工作。

第二个示例使用“注释”,并在您要压缩/丑化代码时使用。压缩你的代码将取代你的服务名称,并会破坏你的代码。由于字符串不会被urligfier替换,因此Angular可以使用它来确定注入什么依赖关系。

看看这个链接上的相关注释部分: https://docs.angularjs.org/guide/di

如果使用任务管理器来缩小你的代码,有很多方法可以有这样的为你做。一个例子可以在这里找到:https://github.com/mzgol/grunt-ng-annotate