How to get a reference of the component "Cart" itself instead of using querySelector() in class Cart?
Also, I want to know is there anyway to access the variable #i from class Cart?
@Component(
selector: '[cart]',
templateUrl: 'cart.html')
class Cart {
handling(){
querySelector("div[cart]");
}
}
<div cart>
<ul>
<li *ngFor="#i of items.values">{{i}}</li>
</ul>
</div>
constructor(private _element:ElementRef)to get the Angular2 element wrapper. nativeElement property has to underlying dom#i, it's a value fromitemswhich is available inCartanyway.