Я определил палитру из углового материала
$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');
И определите ng-strict-di в моем master index.html
<!DOCTYPE html>
<html ng-app="exampleApp" ng-strict-di>
Но у меня есть эта ошибка
Uncaught Error: [$injector:modulerr] Failed to instantiate module appModule due to:
Error: [$injector:strictdi] function($mdThemingProvider) is not using explicit annotation and cannot be invoked in strict mode
http://errors.angularjs.org/1.4.8/$injector/strictdi?p0=function(%24mdThemingProvider)
at http://localhost:4000/bower_components/angular/angular.js:68:12
at Function.annotate [as $$annotate] (http://localhost:4000/bower_components/angular/angular.js:3792:17)
at Object.invoke (http://localhost:4000/bower_components/angular/angular.js:4501:36)
at runInvokeQueue (http://localhost:4000/bower_components/angular/angular.js:4429:35)
at http://localhost:4000/bower_components/angular/angular.js:4437:11
at forEach (http://localhost:4000/bower_components/angular/angular.js:340:20)
at loadModules (http://localhost:4000/bower_components/angular/angular.js:4419:5)
at createInjector (http://localhost:4000/bower_components/angular/angular.js:4344:11)
at doBootstrap (http://localhost:4000/bower_components/angular/angular.js:1676:20)
at Object.angular.resumeBootstrap (http://localhost:4000/bower_components/angular/angular.js:1705:12)
http://errors.angularjs.org/1.4.8/$injector/modulerr?p0=appModule&p1=Error%3A%…F%2Flocalhost%3A4000%2Fbower_components%2Fangular%2Fangular.js%3A1705%3A12)
Есть ли проблема, чтобы поставить фронт в 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');
}]);
Спасибо Панкадж Паркар!
Из документации:
Эта ошибка возникает при попытке вызвать функцию или поставщик, который не был явно аннотирован, в то время как приложение работает со строгим режимом.
Ошибка возникла из '$mdThemingProvider'
что '$mdThemingProvider'
не указывался в качестве зависимости до использования в конфиг-функции.
Чтобы исправить это, вам нужно определить '$mdThemingProvider'
как зависимость:
.config(['$mdThemingProvider',function($mdThemingProvider){
$mdThemingProvider.definePalette('module',{
...
// configuration goes here
});
$mdThemingProvider.theme('default')
.primaryPalette('module');
}]);
.config(['$mdThemingProvider', function($mdThemingProvider) { .... }])
?