Javascript 定义一个'$mdThemingProvider';何时';ng严格的di';是真的
我已经定义了从角材料调色板Javascript 定义一个'$mdThemingProvider';何时';ng严格的di';是真的,javascript,html,angularjs,angular-material,Javascript,Html,Angularjs,Angular Material,我已经定义了从角材料调色板 $mdThemingProvider.definePalette('amazingPaletteName', { '50': 'ffebee', '100': 'ffcdd2', '200': 'ef9a9a', '300': 'e57373', '400': 'ef5350', '500': 'f44336', '600': 'e53935', '700': 'd32f2f', '800': '
$mdThemingProvider.definePalette('amazingPaletteName', {
'50': 'ffebee',
'100': 'ffcdd2',
'200': 'ef9a9a',
'300': 'e57373',
'400': 'ef5350',
'500': 'f44336',
'600': 'e53935',
'700': 'd32f2f',
'800': 'c62828',
'900': 'b71c1c',
'A100': 'ff8a80',
'A200': 'ff5252',
'A400': 'ff1744',
'A700': 'd50000',
'contrastDefaultColor': 'light', // whether, by default, text (contrast)
// on this palette should be dark or light
'contrastDarkColors': ['50', '100', //hues which contrast should be 'dark' by default
'200', '300', '400', 'A100'],
'contrastLightColors': undefined // could also specify this if default was 'dark'
});
$mdThemingProvider.theme('custom2')
.primaryPalette('amazingPaletteName');
并在my master index.html中定义ng strict di
<!DOCTYPE html>
<html ng-app="exampleApp" ng-strict-di>
在ng strict di中放置前端并定义调色板是否存在问题
谢谢
----编辑----
问题是如何使用数组注释
.config(['$mdThemingProvider',function($mdThemingProvider){
$mdThemingProvider.definePalette('module',{
'50': '90ad53',
'100': 'dddddd',
'200': '90ad53',
...
'contrastDefaultColor': 'dddddd', // whether, by default, text (contrast)
// on this palette should be dark or light
'contrastDarkColors': ['50', '100', //hues which contrast should be 'dark' by default
'200', '300', '400', 'A100'],
'contrastLightColors': undefined
});
$mdThemingProvider.theme('default')
.primaryPalette('module');
}]);
感谢潘卡吉·帕克 来自:
当应用程序在启用严格di模式的情况下运行时,尝试调用未显式注释的函数或提供程序时,会发生此错误
出现此错误的原因是,“$mdThemingProvider”
在用于配置函数之前未作为依赖项列出
要解决此问题,您需要将“$mdThemingProvider”
定义为依赖项:
.config(['$mdThemingProvider',function($mdThemingProvider){
$mdThemingProvider.definePalette('module',{
...
// configuration goes here
});
$mdThemingProvider.theme('default')
.primaryPalette('module');
}]);
您是否使用过数组内联DI注释,如
.config(['$mdThemingProvider',function($mdThemingProvider){..}])
?听起来很像,你查过了吗?可能需要自己动手制作。
.config(['$mdThemingProvider',function($mdThemingProvider){
$mdThemingProvider.definePalette('module',{
...
// configuration goes here
});
$mdThemingProvider.theme('default')
.primaryPalette('module');
}]);