It is my app.component.ts:
import { Component } from '@angular/core';
@Component({
templateUrl: 'app/app.component.html',
selector: 'my-app'
})
export class AppComponent {
}
And this is my app.component.html:
<p-tabView>
<p-tabPanel header="Home" leftIcon="fa-bar-chart-o">
<home-app></home-app>
</p-tabPanel>
<p-tabPanel header="Hierarquia" leftIcon="fa-sitemap">
<tree-app></tree-app>
</p-tabPanel>
<p-tabPanel header="Configurações" leftIcon="fa-cog">
<config-app></config-app>
</p-tabPanel>
</p-tabView>
My three components (home, tree and config) are been loaded at the same time when the tabView is loaded. However, I would like that a component was loaded just when its tab was selected. How to do that?
P.S.: if it helps, TabView has an onChange event.
You can use
SystemJsNgModuleLoader
which is used in angular2 routingLive Plunker
First you can write component which will load module:
And then use it in your component:
See also
After much research, I could solve the problem using router. Now the application is really fast.
app.component.ts:
app.component.html:
app.route.ts:
app.module.ts:
Thanks God! =]
Primeng tabview has an "lazy" attribute which is default to "false". You can set it as follows
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.