1. js code acquired using native dom element
There is a ngOnInit in ts file () method, this approach means that after the module is not loaded in the dom is loaded, which means that if your instructions angular dom element in use, and then want to modify dom in this method element is not possible,
However, there is another method ngAfterViewInit () method, the method is performed after dom loaded, so the operation can be acquired dom element on the inside
2. Use @ViewChild get a dom element
- 1. incorporated within parent components used ViewChild
- 2. Use decorator to obtain subassembly parent components used dom element
-
3. Modify the properties dom element in ngAfterViewInit () method.
Two: the formation of mutual value-passing between father and son
1. When the parent component sub-assemblies incoming data calls
2. The subassembly module incorporated Inupt
3. The subassembly @Input received data transmission over parent component
Three: output enable communication Sons component (subassembly active push)
1. Output subassembly and introducing EventEmitter
2. The subassembly instantiated EventEmitter
3. The method of transmitting a
4. The sub-assembly is then accepted parent components
The parent component method response
Here e is broadcast in the subassembly sentence.