相关疑难解决方法(0)

'router-outlet'不是一个已知的元素

我有一个带角度前端的mvc 5项目.我想按照本教程https://angular.io/guide/router中的说明添加路由.所以在我的_Layout.cshtml中我添加了一个

<base href="/">
Run Code Online (Sandbox Code Playgroud)

并在我的app.module中创建了我的路由.但是当我运行这个时,我收到以下错误:

Error: Template parse errors:
    'router-outlet' is not a known element:
    1. If 'router-outlet' is an Angular component, then verify that it is part       of this module.
    2. If 'router-outlet' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA'   to the '@NgModule.schemas' of this component to suppress this message. ("
    <a routerLink="/dashboard">dashboard</a>
    </nav>
    [ERROR ->]<router-outlet></router-outlet>
     "): ng:///AppModule/AppComponent.html@5:0
Run Code Online (Sandbox Code Playgroud)

在我的app.component中

<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)

给出一个错误,告诉我Visual Studio无法解析标签'router-outlet'.有任何建议我如何解决这个错误?我错过了参考或导入或只是忽略了什么?

下面是我的package.json,app.component和app.module

的package.json

{
  "version": "1.0.0",
  "name": "app",
  "private": true,
  "scripts": {},
  "dependencies": {
    "@angular/common": "^4.2.2", …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc-5 angular2-routing angular

61
推荐指数
13
解决办法
11万
查看次数

RouterModule.forRoot调用了两次错误

我正在尝试将Lazy Loading实现到我的应用程序中,但似乎遇到了一个问题,我得到了错误消息:

// External Dependencies
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

// Internal Dependencies
import { MaterialModule } from '../app/configuration/material/material.module';
import { SharedModule } from '../app/application/shared/shared.module';
import { RoutingModule } from '../app/configuration/routing/routing.module';
import { SettingsModule } from '../app/application/settings/settings.module';

import { AppComponent } from './app.component';

import { SearchService } from './application/shared/services/search.service';

@NgModule({
  declarations: [AppComponent],
  imports: [ …
Run Code Online (Sandbox Code Playgroud)

angular-routing angular

11
推荐指数
7
解决办法
1万
查看次数