How do I combine a template reference variable with ngIf?

后端 未结 5 824
抹茶落季
抹茶落季 2020-12-14 06:16
tRefVar is {{tRefVar.foo}}

Even though the

5条回答
  •  天涯浪人
    2020-12-14 06:46

    If you are using Angular 8 you can solve this issue by adding a view child reference and setting the static value to false.

    Example template code:

    
    
    SHIBAMBO!

    Component Code:

    export class EventsComponent {
        @ViewChild('eventsTable', {static: false}) eventsTable: Table;
    
        constructor() {
            console.log(this.eventsTable)
        }
    }
    

    In Angular 9, false will be the default value.

提交回复
热议问题