2
我使用了角度2在asp mvc 5在角度2和ASP mvc找不到页面
当我使用此代码,它的工作,并没有问题。
app.module:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
@NgModule({
imports: [BrowserModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component:
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: '<h1>My First App</h1>'
})
export class AppComponent {
}
并在标头:
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
<base href="/" />
<link rel="stylesheet" href="/styles.css">
<!-- Polyfill(s) for older browsers -->
<script src="/node_modules/core-js/client/shim.min.js"></script>
<script src="/node_modules/zone.js/dist/zone.js"></script>
<script src="/node_modules/reflect-metadata/Reflect.js"></script>
<script src="/node_modules/systemjs/dist/system.src.js"></script>
<script src="/systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
这个代码是工作。它让我看到:My First App
。
,但是当我用这个代码,它告诉我的错误:Error
我用这个代码:
app.module:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { OtherComponent } from './other/other.component';
@NgModule({
imports: [BrowserModule],
declarations: [AppComponent, OtherComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component:
import { Component } from '@angular/core';
import { OtherComponent } from './other/other.component';
@Component({
selector: 'my-app',
template: `<h1>My First App</h1>
<other-app></other-app>
`
})
export class AppComponent {
}
other.component:
import { Component , OnInit } from '@angular/core';
@Component({
selector: 'other-app',
templateUrl: 'app/other/other.component'
})
export class OtherComponent implements OnInit {
Constractor() { }
ngOnInit(){ }
}
other.component.html:
<div class="panel panel-default">
<div class="panel-body">
{{name}}
</div>
</div>
什么问题呢?我怎么解决这个问题 ?