angular2 routing - Cannot find module '@angular/platform/browser' -
i have created angular2 app using ng new myproject, , going bootstrap app. here boot.ts file:
import {bootstrap} '@angular/platform/browser'; import {appcomponent} './app.component' import {router_providers} '@angular/router' bootstrap(appcomponent,[router_providers] ); there 2 problems in file: in first line '@angular/platform/browser' complains
cannot find module '@angular/platform/browser'. and in third line import {router_providers} '@angular/router' complains that:
module '"c:/users/salman/desktop/courses/internship/angular2/qminder/qminder/node_modules/@angular/router/index"' has no exported member 'router_providers'. so how can fix them? there wrong command ng new?
as of angular release candidate version 4 should import bootstrap function following module:
import { bootstrap } '@angular/platform-browser-dynamic'; the router module changed in latest version of angular need create "app.routes.ts" file have following:
import { providerouter, routerconfig } '@angular/router'; const routes: routerconfig = [ { path: 'home', component: homecomponent }, { path: '**', component: pagenotfoundcomponent } ]; export const approuterproviders = [ providerouter(routes) ]; then need import "approuterproviders" , provide "bootstrap" method:
import { bootstrap } '@angular/platform-browser-dynamic'; import { appcomponent } './app.component'; import { approuterproviders } './app.routes'; bootstrap(appcomponent, [ approuterproviders ]) .catch(err => console.error(err)); more information latest router can found here:
Comments
Post a Comment