您必须在字符串数组中注入服务和控制器是有原因的。
如果你想将作用域注入控制器,你必须使用
angular.module('yourApp')
.controller('yourController',['$scope',function($scope){
}]);
缩小将更改变量名称,如果您在注入服务或控制器时不使用该字符串数组,它将像
angular.module('yourApp')
.controller('yourController',function(e){
});
因此,角度将无法理解“e”代表什么,因此会出现错误。
永远记住顺序也很重要。
.directive('mhDashboard', ['$http','authService','apiService', function ($http, authService, apiService) {
return {
restrict: 'EA',
scope: {
name: '@',
dash: '@',
report: '@',
disname: '@',
disdesc: '@',
distot: '@'
},
templateUrl: 'views/dashboard/dashboard-direc.html',
link: function (scope, element, attr) {
scope.linkChk = scope.name;
switch (scope.linkChk) {
case 'Shipped This Week':
scope.url = 'erp/JobShipmentList/PostCpsVwShipmentCount';
scope.shipstatus = "Departure";
scope.period = "ThisWeek";
scope.basicfilter = "Open";
scope.linkName = "Shipments";
scope.linkDesc = "Shipped This Week";
break;
}
}])