I want to insert dynamically attributes to an input html tag, but I don\'t know to to do this:
I\'ve got this code from component side:
import { Componen
If you want to dynamically change the attributes of a single tag, I would recommend you use
@ViewChild
. For example,
import { Component, AfterViewInit, ElementRef } from '@angular/core';
@Component({
selector: 'app-transclusion',
template: `
`,
styleUrls: ['./transclusion.component.css']
})
export class TransclusionComponent implements AfterViewInit {
@ViewChild('foobar') foobar: ElementRef;
constructor() { }
ngAfterViewInit() {
this.foobar.nativeElement.value = 'foobar';
// change other values of element
}
}