Angular ElementRef + Renderer2 using global settings component properties

1. Introducing a selector element

 

 

 

2. Global Settings input angular hook length

ngAfterViewChecked() {
    const input = this.el.nativeElement.querySelectorAll('input');
    if (input) {
      input.forEach(e => {
        this.renderer.setAttribute(e, 'maxlength', '1');
        // console.log(e);
      });
    }
  }

3. If the project is the use of global framework layout may set the properties of the page component in the container

 

 

 

Guess you like

Origin www.cnblogs.com/guanxiaohe/p/11912785.html