You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been commenting about this in #631, but that's closed so opening a new issue.
RC 1 requires routes to be defined by new'ing Route objects instead of passing object literals (see the router documentation). The only way I was able to make the CLI generated router code to work was by modifying it as follows:
import { Component, OnInit } from '@angular/core';
import { HomeComponent } from './+home';
import { Routes, Route, Router, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from '@angular/router';
import { AboutComponent } from './+about';
@Component({
moduleId: module.id,
selector: 'angular-cli-demo-app',
templateUrl: 'angular-cli-demo.component.html',
styleUrls: ['angular-cli-demo.component.css'],
directives: [ROUTER_DIRECTIVES],
providers: [ROUTER_PROVIDERS]
})
@Routes([
new Route({path: '/', component: HomeComponent}), // <---- see new Route({...}) here
new Route({path: '/about', component: AboutComponent})
])
export class AngularCliDemoAppComponent implements OnInit {
title = 'Angular CLI Demo';
constructor(private router: Router) {}
ngOnInit() {
this.router.navigate(['/']);
}
}
Has anyone been able to make the router work with the raw CLI generated code, i.e. just an object literal?
P.S. Also note that the default route is initialized by the code in ngOnInit() - there is no useAsDefault attribute any more.
The text was updated successfully, but these errors were encountered:
I have been commenting about this in #631, but that's closed so opening a new issue.
RC 1 requires routes to be defined by new'ing
Route
objects instead of passing object literals (see the router documentation). The only way I was able to make the CLI generated router code to work was by modifying it as follows:Has anyone been able to make the router work with the raw CLI generated code, i.e. just an object literal?
P.S. Also note that the default route is initialized by the code in
ngOnInit()
- there is nouseAsDefault
attribute any more.The text was updated successfully, but these errors were encountered: