如何处理angular7中的元素引用?

时间:2019-07-05 08:48:32

标签: node.js mongodb include angular7

我想打开行程页面后打开预订信息标签,我正在尝试使用此代码,但无法获取

trip-add.component.ts

public ngOnInit()
{
    this.getTripOnPageLoad(this.tripId, this.clientId);

    let eventTaskId = this._route.snapshot.params['eventTaskId'];
    let bookingId = this._route.snapshot.params['bookingId'];

    console.log(' bookingId ' , bookingId);
    if (bookingId) {
        this.loadBooking = true;
        this.showBookingTab = true;
        this.loadSubBooking = true;


        if(this.bookingInfoTab){

            let el: HTMLElement = this.bookingInfoTab.nativeElement as HTMLElement;
            el.click();
        }
    }

    if (eventTaskId) {

        this._taskService.getTaskById(eventTaskId)
            .subscribe((data: any) => {
                if (data.status === '1') {
                    let el: HTMLElement = this.tab11defaultButton.nativeElement as HTMLElement;
                    el.click();
                    this.loadTask = true;
                    this.editFlag = data.result;
                }
            }, (error: any) => {
                console.log(' Error while taskList :  ' + JSON.stringify(error));
            });
    }
}

trip-add.html

<li  (click)="tabSelectedEvent()">
    <a href="#tab1default" data-toggle="tab">Trip Information</a>
</li>
<li (click)="tabSelectedEvent()">
    <a href="#tab2default" (click)="loadBooking = true; isChangedBooking = !isChangedBooking;"  #bookingTab data-toggle="tab">Bookings 
        <span class="badge bg-purple">{{countInfo.bookings}}</span>
    </a>
</li>
<li  #bookingInfotab  [class.hideBookingTab]="!showBookingTab" >
    <a href="#tab3default" id="bookingInfoTab" #bookingInfoTab data-toggle="tab" >Bookings Information</a>
</li>
<!--<li (click)="tabSelectedEvent()">
    <a href="#tab4default" data-toggle="tab">Receipts</a>
</li>-->
<li [class.hideBookingTab]="!showBookingTab" [selectedIndex] ="2" >
    <a href="#tab5default" (click)="loadPayment = true;" data-toggle="tab">Payments
        <span class="badge bg-purple">{{paymentCounter}}</span>
    </a>
</li>

我要在获取旅行页面后激活激活预订信息标签

0 个答案:

没有答案