What's the proper way of accessing native element in angular2 (2 diff ways)
so I have seen code that uses:
constructor(ele: ElementRef) {
let myEl = ele.nativeElement;
// do some work on myEl such as jQuery(myEl).hide()
...
As well as code that uses native dom via BrowserDomAdapter:
constructor(viewContainer:ViewContainerRef) {
let dom = new BrowserDomAdapter();
let el = viewContainer.element.nativeElement;
let myEle = dom.getElementsByClassName(el, element)[0];
// or jQuery(myEle).hide()
...
I am wondering what's the Pro / Cons and "proper" way of doing things.
Unfortunately, the docs seem scarce still.
I am assuming the latter will give you WebWorkers support through the interface, but it is just my assumption.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…