Configuring routes and bootstrapping the app
In SPA, the routes for our app are defined in the frontend. In Angular 2, we need to define the paths and a component associated with the path that will be rendered for that path.
We provide the routes to the root component, and the root component displays the component bound to the route.
Let's create the root component and routes for our search engine template:
- Place this code in the
index.js
file to to create the root components and routes:var AppComponent = ng.core.Component({ selector: "app", directives: [ng.router.ROUTER_DIRECTIVES], templateUrl: "componentTemplates/app.html" }).Class({ constructor: function(){} }) AppComponent = ng.router.RouteConfig([ { path: "/", component: HomeComponent, name: "Home" }, { path: "/search-result", component: SearchResultComponent, name: "SearchResult" }, { path: "/*path", component: NotFoundComponent, name: "...