Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Angular 2 (click) attribute globally to CSS

In Angular 1, you could simply add

[ngClick],
[data-ng-click],
[x-ng-click] {
    cursor: pointer;
}

and all tags with the ng-click attribute would now have the pointer cursor now. How can we add the Angular 2 (click) attribute in the same way?

like image 399
cbrawl Avatar asked Jan 24 '17 17:01

cbrawl


1 Answers

This is not possible using just the name of an attribute. Angular 2 changes this template:

<div>
    <h2>Hello {{name}}</h2>
    <div (click)="sayhi()"></div>
</div>

to this DOM:

 <div _ngcontent-xwy-0="">
     <h2 _ngcontent-xwy-0="">Hello Angular2</h2>
     <div _ngcontent-xwy-0=""></div>
  </div>

Since there is no way to specify a wildcard attribute name CSS selector (i.e. [_ngcontent-*] { cursor: pointer }, there is no way to achieve this using just CSS.

like image 156
John Hamm Avatar answered Nov 17 '22 04:11

John Hamm