1

Please see the following plunker

I want to be able to select a tab after the tabs have been rendered but I get an error ExpressionChangedAfterItHasBeenCheckedError. The scenario is on refresh of browser if this particular route has an ID value then load the entity and then select the detail tab.

ngAfterViewInit() {
    let id = this.route.snapshot.params['id'];
    if(null!=id) {
      this.loadEntity(id);
      this.tabs.select('detail');
    }
  }

1 Answer 1

1

I solved this by having a variable selected tab in the component and then setting the activeId of the tabs to this variable.

<ngb-tabset [activeId]="selectedTab">

In the onInit of the component I then just set this selectedTab variable to the detail tab if the route contains an ID...

let id = this.route.snapshot.params['id'];
if(null!=id) {
  this.loadEntity(id);
  this.selectedTab = 'detail';
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.