我有一个带角度前端的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)