, , IMHO . "".
Angularish-2 DOM; ElementRef ViewChild. , , .
ElementRef, , . , XSS. "" .
, -, , ViewChild.
:
<input #myinput type="text" />
, winky #myInput. , ol 'DOM id =' '. , , CSS .
In your code: Note. I use ES6 without annotations. but to get the same effect, you must use the @ViewChild annotation. It was good in TS (not in ES6 at all, it took me a while to get it together).
FYI I had to figure out how to do this because I wanted to implement an RxJS stream to do some debouncing and whatnot.
import { Component, ngOnInit, ViewChild } from '@angular/core';
class HomeComponent {
constructor( ) {}
ngOnInit ( ) {
var inputBox = this.myInputRef.nativeElement;
var source = Rx.Observable.fromEvent(inputBox, 'click');
...
}
}
HomeComponent.annotations = [
new Component ( {
templateUrl: './views/home/home.component.html',
queries: { 'myInputRef': new ViewChild ( 'myinput' ) }
} )
];
export { HomeComponent }
It works like a charm. About time, we had something like this in Angular. JQLite really never shortened it.
source
share