如何摆脱AngularJS Material插入头部的多个样式标签? [英] How to get rid off multiple style tags inserted to head by AngularJS Material?
问题描述
AngularJS材质插入具有md-theme-style
属性的多个(大约30个)样式标签.我想这是某种性能调整,但是我宁愿自己做-我不需要外部框架以这种讨厌的方式污染我的HTML.关于如何摆脱样式标签的任何想法?
AngularJS Material inserts multiple (around 30) style tags with md-theme-style
attribute. I guess it's some kind of performance tuning but I would rather do it myself - I don't need an external framework to pollute my HTML in this nasty way. Any thoughts on how to get rid of the style tags?
推荐答案
惰性生成主题
默认情况下,定义时会生成每个主题.您可以使用$mdThemingProvider
By default, every theme is generated when defined. You can disable this in the configuration section using the $mdThemingProvider
angular.module('myApp', ['ngMaterial'])
.config(function($mdThemingProvider) {
//disable theme generation
$mdThemingProvider.generateThemesOnDemand(true);
});
这是我使用的确切语法,它像冠军一样工作. (重要的一点是,这对我们来说也没有破坏任何风格):
Here's the exact syntax I used, and it worked like a champ. (Important to note this didn't break any style for us, either):
.config(['$mdThemingProvider', function($mdThemingProvider) {
$mdThemingProvider.generateThemesOnDemand(true);
}])
知道这似乎是角度的标准也是很有用的.我也不得不拒绝动画.默认情况下,他们几乎为所有内容设置动画.
It may also be useful to know this seems to be a standard for angular. I had to turn the animations down too. By default they were animating pretty much everything.
这篇关于如何摆脱AngularJS Material插入头部的多个样式标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!