javascript - In Angular2 NGmodule .I want to load 2 different sets of route modules based on Condition -


in angular2 .i want load 2 different sets of route modules 1 jobseekers , other employers . the urls same modules jobseekers , employers different . there fore want dynamically load route modules bases on session of login .is there way can ?? or there better way can implemented in angular2

basically want able load ngmodules based on condition

below sample code .

@ngmodule({   imports: [browsermodule, httpmodule,customroutes.getcustomroutes(),             sharedmodule.forroot()],   declarations: [appcomponent],   providers: [     {     provide: app_base_href,     usevalue: '<%= app_base %>'  },     canactivateguard,accountservice, profileservice],   bootstrap: [appcomponent] })  export class appmodule {    constructor(private _http:http,@inject(accountservice) authservice:accountservice) {     } 

// custom route

export class customroutes {    public customroutes;   constructor(@inject(accountservice)  accountservice:accountservice) {     }   getcustomroutes() {     return this.customroutes = (accountservice.getcheckemployer())?jobseekerroutes:employerroutes;   }  } 

// getcustomroutes need static method called in ngmodule . if make static access accountservice object.

(is there better way achieve feature of loading different routes based on user session)

unfortunately configuring routes @ runtime not supported @ time. routes specified when angular application bootstrapped 1 cannot change them afterwards.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -