How to lazy load Angular 2 components in a TabView (PrimeNG)?

前端 未结 5 865
野的像风
野的像风 2020-12-30 16:37

It is my app.component.ts:

import { Component } from \'@angular/core\';

@Component({
    templateUrl: \'app/app.component.html\',
    selector: \'my-app\'
}         


        
5条回答
  •  孤独总比滥情好
    2020-12-30 17:14

    I've tried lazy attribute which doesn't work. Using router and ModuleLoader are great but a bit complex. If you want to keep your application not too much complex, the easiest solution is to use NgIf for rendering tabs.

    
       
          
       
       
          
       
       
          
       
    
    

    And define a flag to render the selected tab.

    handleChange(e) {
       this.activeTab = e.index;
    }
    

提交回复
热议问题