0

我写了绑定脚本ngAfterViewInit,还是绑定到undefined,输入加载到DOM后在哪里调用

HTML

<input type="text" *ngIf="showLastContactedDate" #dateRangeLastContacted placeholder="Choose Period" (cancelDaterangepicker)="calendarCanceled($event)" (applyDaterangepicker)="calendarApplied($event)" 
 daterangepicker [options]="options"/>

TS

export class FilterContactsDialogComponent implements OnInit, AfterViewInit {
    @ViewChild('dateRangeLastContacted') dateRangeLastContacted;

    ngOnInit() {}

    ngAfterViewInit(){


    response = //calling a service method
        setTimeout(() => {
            this.dateRangeLastContacted.nativeElement.value = response.someValue;
        },0);
    }
}
4

0 回答 0