I am using Angular2 to create an application i which i need to navigate between tabs using a button present inside the tabs.
my html is as the following :
This can be achieved using selectedIndex input variable using the below code
Content 1
Content 2
and your typescript code will be
@Component({
selector: 'tabs-sample',
templateUrl: './tabsSample.html',
})
export class TabsSample {
selectedIndex:number=0;
clickMe(){
this.selectedIndex=1;
}
}
Update 1: Based on comment.
You can use the selectedIndexChange method to fix that error as below
and your code will have
selectedIndexChange(val :number ){
this.selectedIndex=val;
}
Updated in the plunk as well.
LIVE DEMO