Alright, now let's add another route to our app. We'll call it 'foo'. We can easily do this with the yo angular-fullstack:route subgenerator command:
$yoangular-fullstack:routefoo? What module name would you like to use? (aftestApp.foo)? What module name would you like to use? aftestApp.foo? Where would you like to create this route? (client/app/)? Where would you like to create this route? client/app/? What will the url of your route be? (/foo)? What will the url of your route be? /foocreateclient\app\foo\foo.component.jscreateclient\app\foo\foo.component.spec.jscreateclient\app\foo\foo.htmlcreateclient\app\foo\foo.scssIntheparentofthiscomponent,youshouldnowimportthiscomponentandadditasadependency:importFooComponentfrom'./foo/foo.component';...exportangular.module('myParentModule', [FooComponent]);
We give it our route name ('foo'), and a few more details: the name of the Angular module to create ('myApp.foo'), which folder to put the route under ('client/app/foo/'), and the URL of the route ('localhost:3000/foo').
This will create an Angular component with an Angular module (foo.component.js), a template file (foo.html), a CSS file (foo.scss), a unit test file (foo.component.spec.js), and a routing file (foo.routes.js).
Since we're using Webpack, We'll need to import our component somewhere. Since this is a generic app route (and for simplicity), we'll import it in app.js, under our root Angular module, like so:
client/app/app.js
Now that we've imported our new Angular module and added it to the dependency list of our root Angular module, we should be able to navigate to http://localhost:3000/foo and see our new route:
It's not a very impressive page right now, but it works.
Now, our user's aren't going to know to go to the /foo route. Let's add a navbar entry for it.
client/components/navbar/navbar.component.js
Easy enough. Now we should see our entry for 'Foo' in our navbar. It should also be highlighted if you're still on the '/foo' route.
You can read about all the other subgenerators that are available in the Generators section of the docs.