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:

  1. 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: ...

Get JavaScript: Moving to ES2015 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.