Hi All!
Is it possible to load Angular2 Routes from remote json file?
[
{
"path": "users",
"component": "views.UserTreeView"
}
]
@Injectable()
export class NavigationService {
constructor(private http: Http) {
}
loadRoutes(): Observable<Routes> {
debugger;
return this.http.get(navigationUrl)
.map((r: Response) => r.json())
.map((items: Array<any>) => {
return items.map(i => <any>{ path: i.path, component:
i.component
})
});
}
}
And load in app.component
ngOnInit() {
// Маршруты
this.navigationService
.loadRoutes()
.subscribe(routes => {
this.router.resetConfig(routes);
this.router.navigate(['users']);
});
}
Such approach always gets error-
*No component factory found for views.UserTreeView*Thanks.
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.