{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular-cli/issues/2794","repository_url":"https://api.github.com/repos/angular/angular-cli","labels_url":"https://api.github.com/repos/angular/angular-cli/issues/2794/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular-cli/issues/2794/comments","events_url":"https://api.github.com/repos/angular/angular-cli/issues/2794/events","html_url":"https://github.com/angular/angular-cli/pull/2794","id":184139213,"number":2794,"title":"fix(generate): stop default browser error from ng new --routing","user":{"login":"Meligy","id":171637,"avatar_url":"https://avatars.githubusercontent.com/u/171637?v=3","gravatar_id":"","url":"https://api.github.com/users/Meligy","html_url":"https://github.com/Meligy","followers_url":"https://api.github.com/users/Meligy/followers","following_url":"https://api.github.com/users/Meligy/following{/other_user}","gists_url":"https://api.github.com/users/Meligy/gists{/gist_id}","starred_url":"https://api.github.com/users/Meligy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Meligy/subscriptions","organizations_url":"https://api.github.com/users/Meligy/orgs","repos_url":"https://api.github.com/users/Meligy/repos","events_url":"https://api.github.com/users/Meligy/events{/privacy}","received_events_url":"https://api.github.com/users/Meligy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/angular-cli/labels/cla:%20yes","name":"cla: yes","color":"0e8a16"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-20T05:36:15Z","updated_at":"2016-10-23T20:17:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/angular/angular-cli/pulls/2794","html_url":"https://github.com/angular/angular-cli/pull/2794","diff_url":"https://github.com/angular/angular-cli/pull/2794.diff","patch_url":"https://github.com/angular/angular-cli/pull/2794.patch"},"body":"Fixes the following issue with `ng new`:\r\n\r\n## Problem\r\n\r\nIf you run:\r\n\r\n```\r\nng new client --routing\r\ncd client\r\nng serve\r\n```\r\n\r\nIn the browser you see an error because the routes do not match anything.\r\n\r\nThis happens because the routes array is empty, so, nothing matches ... nothing.\r\n\r\nIt's still not a good 1st time experience though, to throw error by default.\r\n\r\n(Error log follows at the end)\r\n\r\n## Solution\r\n\r\nThe correct way to fix this is to have another component and setup the routing to show it inside the `AppComponent`.\r\n\r\nThis leads to several decisions, like what to name the component, etc. which the CLI would rather not be involved in.\r\n\r\nSo, this PR puts the minimalist code that can make the browser NOT show errors, leave a good start for users to add their own routes, and doesn't make any special decisions.\r\n\r\n## Notes\r\n\r\n### Tests\r\n\r\nSince tests seem to only check for files being present - and not check for their content, no tests were added or modified.\r\n\r\n### AoT\r\n\r\nThis PR is different from #2680. The error this PR fixes is NOT AoT specific at all. It's running plain `ng serve` after creating default project structure with no modifications.\r\n\r\nHence, it's also different from the problem described in #2680. Both are issues that happen in the browser console, but the problem this PR addresses happens with the user NOT adding any routes (or making any project modifications at all after using `ng new --routing`), and it happens *without* AoT.\r\n\r\nThe problem in #2680 happens after the user adds syntactically correct routes, and only happens when serving with `--aot`. \r\n\r\n### Error Details\r\n\r\nThis is the specific error that shows in the browser following the steps mentioned above:\r\n\r\n```\r\nlang.js:234Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.\r\nerror_handler.js:47EXCEPTION: Uncaught (in promise): Error: Cannot match any routes: ''\r\nError: Cannot match any routes: ''\r\n    at ApplyRedirects.noMatchError (http://localhost:4200/main.bundle.js:60150:16)\r\n    at CatchSubscriber.selector (http://localhost:4200/main.bundle.js:60128:29)\r\n    at CatchSubscriber.error (http://localhost:4200/main.bundle.js:66368:31)\r\n    at MapSubscriber.Subscriber._error (http://localhost:4200/main.bundle.js:6332:26)\r\n    at MapSubscriber.Subscriber.error (http://localhost:4200/main.bundle.js:6306:18)\r\n    at CatchSubscriber.error (http://localhost:4200/main.bundle.js:66371:34)\r\n    at FirstSubscriber._complete (http://localhost:4200/main.bundle.js:66530:25)\r\n    at FirstSubscriber.Subscriber.complete (http://localhost:4200/main.bundle.js:6318:18)\r\n    at MergeAllSubscriber._complete (http://localhost:4200/main.bundle.js:31845:30)\r\n    at MergeAllSubscriber.Subscriber.complete (http://localhost:4200/main.bundle.js:6318:18)ErrorHandler.handleError @ error_handler.js:47next @ application_ref.js:272schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:119onHandleError @ ng_zone_impl.js:64ZoneDelegate.handleError @ zone.js:236Zone.runGuarded @ zone.js:131_loop_1 @ zone.js:412drainMicroTaskQueue @ zone.js:421\r\nerror_handler.js:52ORIGINAL STACKTRACE:ErrorHandler.handleError @ error_handler.js:52next @ application_ref.js:272schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:119onHandleError @ ng_zone_impl.js:64ZoneDelegate.handleError @ zone.js:236Zone.runGuarded @ zone.js:131_loop_1 @ zone.js:412drainMicroTaskQueue @ zone.js:421\r\nerror_handler.js:53Error: Uncaught (in promise): Error: Cannot match any routes: ''\r\nError: Cannot match any routes: ''\r\n    at ApplyRedirects.noMatchError (apply_redirects.js:89)\r\n    at CatchSubscriber.selector (apply_redirects.js:67)\r\n    at CatchSubscriber.error (catch.js:52)\r\n    at MapSubscriber.Subscriber._error (Subscriber.js:128)\r\n    at MapSubscriber.Subscriber.error (Subscriber.js:102)\r\n    at CatchSubscriber.error (catch.js:55)\r\n    at FirstSubscriber._complete (first.js:143)\r\n    at FirstSubscriber.Subscriber.complete (Subscriber.js:114)\r\n    at MergeAllSubscriber._complete (mergeAll.js:94)\r\n    at MergeAllSubscriber.Subscriber.complete (Subscriber.js:114)\r\n    at resolvePromise (zone.js:468)\r\n    at zone.js:445\r\n    at ZoneDelegate.invoke (zone.js:232)\r\n    at Object.onInvoke (ng_zone_impl.js:43)\r\n    at ZoneDelegate.invoke (zone.js:231)\r\n    at Zone.run (zone.js:114)\r\n    at zone.js:502\r\n    at ZoneDelegate.invokeTask (zone.js:265)\r\n    at Object.onInvokeTask (ng_zone_impl.js:34)\r\n    at ZoneDelegate.invokeTask (zone.js:264)ErrorHandler.handleError @ error_handler.js:53next @ application_ref.js:272schedulerFn @ async.js:82SafeSubscriber.__tryOrUnsub @ Subscriber.js:223SafeSubscriber.next @ Subscriber.js:172Subscriber._next @ Subscriber.js:125Subscriber.next @ Subscriber.js:89Subject.next @ Subject.js:55EventEmitter.emit @ async.js:74onError @ ng_zone.js:119onHandleError @ ng_zone_impl.js:64ZoneDelegate.handleError @ zone.js:236Zone.runGuarded @ zone.js:131_loop_1 @ zone.js:412drainMicroTaskQueue @ zone.js:421\r\nzone.js:388Unhandled Promise rejection: Cannot match any routes: '' ; Zone: angular ; Task: Promise.then ; Value: Error: Cannot match any routes: ''(…) Error: Cannot match any routes: ''\r\n    at ApplyRedirects.noMatchError (http://localhost:4200/main.bundle.js:60150:16)\r\n    at CatchSubscriber.selector (http://localhost:4200/main.bundle.js:60128:29)\r\n    at CatchSubscriber.error (http://localhost:4200/main.bundle.js:66368:31)\r\n    at MapSubscriber.Subscriber._error (http://localhost:4200/main.bundle.js:6332:26)\r\n    at MapSubscriber.Subscriber.error (http://localhost:4200/main.bundle.js:6306:18)\r\n    at CatchSubscriber.error (http://localhost:4200/main.bundle.js:66371:34)\r\n    at FirstSubscriber._complete (http://localhost:4200/main.bundle.js:66530:25)\r\n    at FirstSubscriber.Subscriber.complete (http://localhost:4200/main.bundle.js:6318:18)\r\n    at MergeAllSubscriber._complete (http://localhost:4200/main.bundle.js:31845:30)\r\n    at MergeAllSubscriber.Subscriber.complete (http://localhost:4200/main.bundle.js:6318:18)consoleError @ zone.js:388_loop_1 @ zone.js:417drainMicroTaskQueue @ zone.js:421\r\nzone.js:390Error: Uncaught (in promise): Error: Cannot match any routes: ''(…)consoleError @ zone.js:390_loop_1 @ zone.js:417drainMicroTaskQueue @ zone.js:421\r\n```"},"comment":{"url":"https://api.github.com/repos/angular/angular-cli/issues/comments/255611528","html_url":"https://github.com/angular/angular-cli/pull/2794#issuecomment-255611528","issue_url":"https://api.github.com/repos/angular/angular-cli/issues/2794","id":255611528,"user":{"login":"filipesilva","id":4172079,"avatar_url":"https://avatars.githubusercontent.com/u/4172079?v=3","gravatar_id":"","url":"https://api.github.com/users/filipesilva","html_url":"https://github.com/filipesilva","followers_url":"https://api.github.com/users/filipesilva/followers","following_url":"https://api.github.com/users/filipesilva/following{/other_user}","gists_url":"https://api.github.com/users/filipesilva/gists{/gist_id}","starred_url":"https://api.github.com/users/filipesilva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filipesilva/subscriptions","organizations_url":"https://api.github.com/users/filipesilva/orgs","repos_url":"https://api.github.com/users/filipesilva/repos","events_url":"https://api.github.com/users/filipesilva/events{/privacy}","received_events_url":"https://api.github.com/users/filipesilva/received_events","type":"User","site_admin":false},"created_at":"2016-10-23T20:17:08Z","updated_at":"2016-10-23T20:17:08Z","body":"The CI failure is fixed with https://github.com/angular/angular-cli/pull/2832.\r\n\r\n@Brocco can you review the PR changes?"}}
{"actor":{"display_login":"filipesilva"}}