简体   繁体   English

Angular 2 Block UI组件

[英]Angular 2 block ui component

What is the proper way to block the ui of a component in Angular 2? 在Angular 2中阻止组件ui的正确方法是什么?

Something like this 像这样

<component [blockUI]="true"></component>

In the component's less file put: 在组件的less文件中:

:host {
    pointer-events: none;
}

If you have components below, they will get the clicks, if you'd like to prevent this, instead of the css do: 如果您下面有组件,则如果您想防止这种情况发生,他们将获得点击,而不是CSS:

<component (click)="$event.preventDefault()">

to make it dynamic, assuming you use less and have a variable called notInteractive : 假设您使用较少并具有一个名为notInteractive的变量,以使其动态notInteractive

:host {
  &.not-interactive {
    pointer-events: none;
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM