./src/app/app.module.ts 中的错误未找到模块
ERROR in ./src/app/app.module.ts Module not found
我正在研究 angular-cli。我收到以下错误。
ERROR in ./src/app/app.module.ts
Module not found: Error: Can't resolve '@angular/router/src/router_module' in
'E:\xampp\Angular-cli\Login\src\app'
@ ./src/app/app.module.ts 13:0-69
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
我的 node_module 中有这个库 @angular/router/src/router_module。 缺少什么?
这是必需的文件。
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AdminAccount } from './admin/admin.component';
import { LoginForm } from './login/login.component';
import { FileData } from './filedata/filedata.component';
import { ROUTER_PROVIDERS } from "@angular/router/src/router_module";
import { RouterModule, Routes, ROUTES } from "@angular/router";
import { Http, Response } from "@angular/http";
import { Route } from './router/router.component';
@NgModule(
{
imports: [RouterModule ,Route, BrowserModule, Http, Response, AdminAccount, LoginForm, FileData, Route],
declarations: [AppComponent],
providers: [ROUTER_PROVIDERS],
bootstrap: [AppComponent]
})
export class AppModule { }
router.component.ts
import { Component, OnInit } from '@angular/core';
import { RouterModule } from "@angular/router";
import { LoginForm } from "../login/login.component";
import { AdminAccount } from "../admin/admin.component";
export const Route = RouterModule.forRoot(
[
{ path: '/', component: LoginForm },
{ path: '/admin', component: AdminAccount }
]);
app.component.ts
import { Component } from "@angular/core";
import { LoginForm } from "./login/login.component";
import { AdminAccount } from "./admin/admin.component";
import { Routes, RouterModule } from "@angular/router";
import { FileData } from "./filedata/filedata.component";
@Component(
{
selector: "root",
templateUrl: "./app.component.html",
})
export class AppComponent {}
如果需要更多文件,请告诉我。
@Fahad Nasir 这是 AdminAcount。
import { Component, OnInit } from '@angular/core';
import { Router } from "@angular/router";
@Component(
{
selector: "admin",
templateUrl: "./admin.component.html",
})
export class AdminAccount
{
adminUser = document.cookie.split("??")[0];
adminPass = document.cookie.split("??")[1];
constructor(public router: Router)
{
if (document.cookie !== undefined)
{
if (this.adminUser == "admin" && this.adminPass == "admin")
{
console.log("Welcome!");
}
else
{
this.router.navigate(["Loginform"]);
console.log("Redirect!");
}
}
else
{
console.log("Error: Undefined Login!");
}
}
}
Here Have a look
我正在研究 angular-cli。我收到以下错误。
ERROR in ./src/app/app.module.ts
Module not found: Error: Can't resolve '@angular/router/src/router_module' in
'E:\xampp\Angular-cli\Login\src\app'
@ ./src/app/app.module.ts 13:0-69
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
我的 node_module 中有这个库 @angular/router/src/router_module。 缺少什么?
这是必需的文件。
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AdminAccount } from './admin/admin.component';
import { LoginForm } from './login/login.component';
import { FileData } from './filedata/filedata.component';
import { ROUTER_PROVIDERS } from "@angular/router/src/router_module";
import { RouterModule, Routes, ROUTES } from "@angular/router";
import { Http, Response } from "@angular/http";
import { Route } from './router/router.component';
@NgModule(
{
imports: [RouterModule ,Route, BrowserModule, Http, Response, AdminAccount, LoginForm, FileData, Route],
declarations: [AppComponent],
providers: [ROUTER_PROVIDERS],
bootstrap: [AppComponent]
})
export class AppModule { }
router.component.ts
import { Component, OnInit } from '@angular/core';
import { RouterModule } from "@angular/router";
import { LoginForm } from "../login/login.component";
import { AdminAccount } from "../admin/admin.component";
export const Route = RouterModule.forRoot(
[
{ path: '/', component: LoginForm },
{ path: '/admin', component: AdminAccount }
]);
app.component.ts
import { Component } from "@angular/core";
import { LoginForm } from "./login/login.component";
import { AdminAccount } from "./admin/admin.component";
import { Routes, RouterModule } from "@angular/router";
import { FileData } from "./filedata/filedata.component";
@Component(
{
selector: "root",
templateUrl: "./app.component.html",
})
export class AppComponent {}
如果需要更多文件,请告诉我。
@Fahad Nasir 这是 AdminAcount。
import { Component, OnInit } from '@angular/core';
import { Router } from "@angular/router";
@Component(
{
selector: "admin",
templateUrl: "./admin.component.html",
})
export class AdminAccount
{
adminUser = document.cookie.split("??")[0];
adminPass = document.cookie.split("??")[1];
constructor(public router: Router)
{
if (document.cookie !== undefined)
{
if (this.adminUser == "admin" && this.adminPass == "admin")
{
console.log("Welcome!");
}
else
{
this.router.navigate(["Loginform"]);
console.log("Redirect!");
}
}
else
{
console.log("Error: Undefined Login!");
}
}
}
Here Have a look