禁用全局涟漪效应角度2应用程序 [英] Disable globally ripple effect angular 2 app
问题描述
我有一个使用材料2的应用程序,我想全局禁用使用该材料的所有组件或指令的涟漪效应.我不想做这个覆盖CSS类的事情.我想到的一件事是创建一个指令,该指令可以扩展MdRipple,然后覆盖其属性,不确定.我想知道您的意见或示例,如何以正确的方式完成此任务.
I have an app which is using material 2, i would like to globally disable the ripple effect for all components or directives that use it. I don't want to do this overriding css classes. One thing that comes in my mind is creating a directive which can extend MdRipple and then override its properties, not sure tho. I would like to know your opinion or example how this can be done in the right way.
推荐答案
提供程序在最新版本中已更改.您需要使用MAT_RIPPLE_GLOBAL_OPTIONS而不是MD_RIPPLE_GLOBAL_OPTIONS.
The provider changed in recent versions. You need to use MAT_RIPPLE_GLOBAL_OPTIONS not MD_RIPPLE_GLOBAL_OPTIONS.
更新您的AppModule.ts
Update your AppModule.ts
...
import { MAT_RIPPLE_GLOBAL_OPTIONS, RippleGlobalOptions } from '@angular/material';
const globalRippleConfig: RippleGlobalOptions = {
disabled: true
};
@NgModule({
imports: [
...
],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ],
providers: [{provide: MAT_RIPPLE_GLOBAL_OPTIONS, useValue: globalRippleConfig}]
})
export class AppModule { }
这篇关于禁用全局涟漪效应角度2应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!