Reputation: 1821
in a component, im attempting to target a dom node and change it's style but this does not work, can anyone tell me what i am doing wrong here?
@Input() progress:number = 0;
...
ngOnChanges() {
this.progressInnerEl = this.elRef.nativeElement.querySelector('.progress-inner');
this.renderer.setStyle(this.progressInnerEl, 'width', this.progress+'%');
}
Upvotes: 18
Views: 40032
Reputation: 451
Try this:
@HostListener('focus') onFocus() {
this._renderer.setStyle(this._el.nativeElement, 'width', '200px');
BTW Renderer is deprecated, so Renderer.setElementStyle
was changed to Renderer2.setStyle
.
Upvotes: 40