Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
Acceda a la plantilla @ViewChild desde ng-content

¿Es posible usar plantillas en combinación con ng-content como se describe aquí?

componente de la aplicación:

 <table-column> <template #template let-item="item"> <input type="text" [(ngModel)]="item.foo" /> </template> </table-column>

componente de columna de tabla:

 @Component({ selector: 'table-column', template: '<ng-content></ng-content>' }) export class TableColumnComponent implements OnInit { @ViewChild('template') template; ngOnInit() { console.log(this.template); // undefined // create column object with template and different metadata... }); }

Plunker ?

El problema que tengo no está undefined usando diferentes ganchos de ciclo de vida (ngOnInit, ngAfterViewInit)...

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Si desea buscar dentro de Light DOM, debe usar @ContentChild y esperar hasta que ngAfterContentInit enganche

 @ContentChild('template') template; ngAfterContentInit() { console.log(this.template); }

Ver también

  • ¿Cuál es la diferencia entre @ViewChild y @ContentChild?
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!