{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular-cli/issues/663","repository_url":"https://api.github.com/repos/angular/angular-cli","labels_url":"https://api.github.com/repos/angular/angular-cli/issues/663/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular-cli/issues/663/comments","events_url":"https://api.github.com/repos/angular/angular-cli/issues/663/events","html_url":"https://github.com/angular/angular-cli/issues/663","id":153520487,"number":663,"title":"Incorrect routes generated for angular 2 RC 1","user":{"login":"nareshbhatia","id":1220198,"avatar_url":"https://avatars.githubusercontent.com/u/1220198?v=3","gravatar_id":"","url":"https://api.github.com/users/nareshbhatia","html_url":"https://github.com/nareshbhatia","followers_url":"https://api.github.com/users/nareshbhatia/followers","following_url":"https://api.github.com/users/nareshbhatia/following{/other_user}","gists_url":"https://api.github.com/users/nareshbhatia/gists{/gist_id}","starred_url":"https://api.github.com/users/nareshbhatia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nareshbhatia/subscriptions","organizations_url":"https://api.github.com/users/nareshbhatia/orgs","repos_url":"https://api.github.com/users/nareshbhatia/repos","events_url":"https://api.github.com/users/nareshbhatia/events{/privacy}","received_events_url":"https://api.github.com/users/nareshbhatia/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/angular-cli/labels/command:%20generate","name":"command: generate","color":"c7def8"},{"url":"https://api.github.com/repos/angular/angular-cli/labels/priority:%202%20(required)","name":"priority: 2 (required)","color":"0052cc"},{"url":"https://api.github.com/repos/angular/angular-cli/labels/type:%20chore","name":"type: chore","color":"eeeeee"}],"state":"closed","locked":false,"assignee":{"login":"Brocco","id":1565117,"avatar_url":"https://avatars.githubusercontent.com/u/1565117?v=3","gravatar_id":"","url":"https://api.github.com/users/Brocco","html_url":"https://github.com/Brocco","followers_url":"https://api.github.com/users/Brocco/followers","following_url":"https://api.github.com/users/Brocco/following{/other_user}","gists_url":"https://api.github.com/users/Brocco/gists{/gist_id}","starred_url":"https://api.github.com/users/Brocco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Brocco/subscriptions","organizations_url":"https://api.github.com/users/Brocco/orgs","repos_url":"https://api.github.com/users/Brocco/repos","events_url":"https://api.github.com/users/Brocco/events{/privacy}","received_events_url":"https://api.github.com/users/Brocco/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2016-05-06T19:20:52Z","updated_at":"2016-05-07T02:27:34Z","closed_at":"2016-05-07T02:27:34Z","body":"I have been commenting about this in https://github.com/angular/angular-cli/issues/631, but that's closed so opening a new issue.\r\n\r\nRC 1 requires routes to be defined by new'ing `Route` objects instead of passing object literals (see the [router documentation](https://angular.io/docs/ts/latest/guide/router.html#!#configuration)). The only way I was able to make the CLI generated router code to work was by modifying it as follows: \r\n\r\n    import { Component, OnInit } from '@angular/core';\r\n    import { HomeComponent } from './+home';\r\n    import { Routes, Route, Router, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from '@angular/router';\r\n    import { AboutComponent } from './+about';\r\n\r\n    @Component({\r\n      moduleId: module.id,\r\n      selector: 'angular-cli-demo-app',\r\n      templateUrl: 'angular-cli-demo.component.html',\r\n      styleUrls: ['angular-cli-demo.component.css'],\r\n      directives: [ROUTER_DIRECTIVES],\r\n      providers: [ROUTER_PROVIDERS]\r\n    })\r\n    @Routes([\r\n      new Route({path: '/', component: HomeComponent}),      // <---- see new Route({...}) here\r\n      new Route({path: '/about', component: AboutComponent})\r\n    ])\r\n    export class AngularCliDemoAppComponent implements OnInit {\r\n      title = 'Angular CLI Demo';\r\n\r\n      constructor(private router: Router) {}\r\n\r\n      ngOnInit() {\r\n        this.router.navigate(['/']);\r\n      }\r\n    }\r\n\r\nHas anyone been able to make the router work with the raw CLI generated code, i.e. just an object literal?\r\n\r\nP.S. Also note that the default route is initialized by the code in `ngOnInit()` - there is no `useAsDefault` attribute any more."},"comment":{"url":"https://api.github.com/repos/angular/angular-cli/issues/comments/217599850","html_url":"https://github.com/angular/angular-cli/issues/663#issuecomment-217599850","issue_url":"https://api.github.com/repos/angular/angular-cli/issues/663","id":217599850,"user":{"login":"nareshbhatia","id":1220198,"avatar_url":"https://avatars.githubusercontent.com/u/1220198?v=3","gravatar_id":"","url":"https://api.github.com/users/nareshbhatia","html_url":"https://github.com/nareshbhatia","followers_url":"https://api.github.com/users/nareshbhatia/followers","following_url":"https://api.github.com/users/nareshbhatia/following{/other_user}","gists_url":"https://api.github.com/users/nareshbhatia/gists{/gist_id}","starred_url":"https://api.github.com/users/nareshbhatia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nareshbhatia/subscriptions","organizations_url":"https://api.github.com/users/nareshbhatia/orgs","repos_url":"https://api.github.com/users/nareshbhatia/repos","events_url":"https://api.github.com/users/nareshbhatia/events{/privacy}","received_events_url":"https://api.github.com/users/nareshbhatia/received_events","type":"User","site_admin":false},"created_at":"2016-05-07T02:27:34Z","updated_at":"2016-05-07T02:27:34Z","body":"Just installed 1.0.0-beta.0 and I cannot reproduce the problem any more. Closing the issue."}}