Angular 中的基本模块种类
Kind of base module in Angular
我有一个 angular 模块,其中有一些配置代码,例如:
angular.module('qrApp').config(['$httpProvider', '$sceDelegateProvider', function ($httpProvider, $sceDelegateProvider) {
// configuring providers
}]);
qrApp.directive('fileModel', ['$parse', function ($parse) {
// custom directive here
}]);
现在我需要另一个新模块,它将具有相同的配置和指令设置,最好的方法是不重复代码但有某种 "base" 模块以便两者都可以继承它等等有相同的设置。谢谢
您可以将通用代码放在单独的模块中,并将该模块添加到模块的依赖列表中
//common.js
angular.module('common', []).config(...).directive(...);
然后使用它
angular.module('qrApp', ['common']);
我有一个 angular 模块,其中有一些配置代码,例如:
angular.module('qrApp').config(['$httpProvider', '$sceDelegateProvider', function ($httpProvider, $sceDelegateProvider) {
// configuring providers
}]);
qrApp.directive('fileModel', ['$parse', function ($parse) {
// custom directive here
}]);
现在我需要另一个新模块,它将具有相同的配置和指令设置,最好的方法是不重复代码但有某种 "base" 模块以便两者都可以继承它等等有相同的设置。谢谢
您可以将通用代码放在单独的模块中,并将该模块添加到模块的依赖列表中
//common.js
angular.module('common', []).config(...).directive(...);
然后使用它
angular.module('qrApp', ['common']);