fix(generate): stop default browser error from ng new --routing#2794
Closed
Meligy wants to merge 1 commit intoangular:masterfrom
Closed
fix(generate): stop default browser error from ng new --routing#2794Meligy wants to merge 1 commit intoangular:masterfrom
Meligy wants to merge 1 commit intoangular:masterfrom
Conversation
Contributor
Author
|
That failing check, looks like it's been failing for a long while regardless of this PR, looking at https://ci.appveyor.com/project/AngularCLI/angular-cli/history |
Contributor
Contributor
Author
|
Hi again guys. How's that looking now? Do you think it's OK to go in beta.20? Does it need more work? Or some review first? Do you think it's not worth it and prefer to close it? Thanks a lot. |
Brocco
approved these changes
Nov 3, 2016
bc58cb5 to
31fc6b4
Compare
31fc6b4 to
f974d40
Compare
MRHarrison
pushed a commit
to MRHarrison/angular-cli
that referenced
this pull request
Feb 9, 2017
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the following issue with
ng new:Problem
If you run:
In the browser you see an error (Error log follows at the end). The error happens in the browser console, and it's a symptom of the route matching not finding any routes to match.
The app is initialized with an empty routes array, so when the routing module tries to use the routes array to match the URL
http://localhost:4200/, it gets nothing, because the array is empty.Makes sense, but it's still not a good 1st time experience though, to throw error by default, when all the user did was creating a new project, relying on the CLI for good defaults.
Solution
The correct way to fix this is to have another component and setup the routing to show it inside the
AppComponent.This leads to several decisions, like what to name the component, etc. which the CLI would rather not be involved in.
So, 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.
Notes
Tests
Since tests seem to only check for files being present - and not check for their content, no tests were added or modified.
AoT
This PR is different from #2680. The error this PR fixes is NOT AoT specific at all. It's running plain
ng serveafter creating default project structure with no modifications.Hence, 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.The problem in #2680 happens after the user adds syntactically correct routes, and only happens when serving with
--aot.Error Details
This is the specific error that shows in the browser following the steps mentioned above: