我正在努力将我的控制器、工厂和指令重构为推荐的Angular 风格指南 https://github.com/johnpapa/angular-styleguide#file-templates-and-snippets for 角度片段 https://github.com/johnpapa/angular-styleguide/tree/master/assets/sublime-angular-snippets.
我已经使控制器和工厂能够与新样式正常工作,但不能与指令一起工作。
Unknown provider: $scopeProvider <- $scope <- platformHeaderDirective
新的指令风格有错误:
(function() { "use strict";
angular
.module('platformHeaderDirectives', [])
.directive('platformHeader', directive);
directive.$inject = ['$scope'];
/* @ngInject */
function directive ($scope) {
var directive = {
templateUrl : "header/platform_header/platformHeader.html",
restrict : "E",
replace : true,
bindToController: true,
controller: Controller,
controllerAs: 'vm',
link: link,
scope: {
}
};
return directive;
function link(scope, element, attrs) {
}
}
/* @ngInject */
function Controller () {
}
})();
我的旧工作指令不会引发错误:
(function() { "use strict";
angular.module('platformHeaderDirectives', [])
.directive('platformHeader', function() {
return {
templateUrl : "header/platform_header/platformHeader.html",
restrict : "E",
replace : true,
scope : false,
controller : ['$scope',
function($scope) {
/** Init platformHeader scope */
// var vs = $scope;
}]
}
});
})();