Angular 2 with MVC 5(创建新组件)

时间:2016-12-12 15:35:38

标签: angular

我正在开发一个使用带有MVC 5框架的angular 2的项目。我已通过本指南成功运行了该项目:http://www.mithunvp.com/using-angular-2-asp-net-mvc-5-visual-studio/

现在,我想创建一个新组件(test.component)。文件夹结构为Folder Structure

当我添加对组件的引用时。它提示无法找到test.component的错误。

boot.ts

///<reference path="./../typings/globals/core-js/index.d.ts"/>
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app';
import { TestComponent } from './test/test.component';

@NgModule({
    imports: [BrowserModule ],
    declarations: [AppComponent, TestComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }

app.ts

import { Component } from '@angular/core';
@Component({
    selector: 'my-app',
    template: `
      <h1>This is cool</h1>
      <fa-test></fa-test>      
  `,

})
export class AppComponent {
    title = 'ASP.NET MVC 5 with Angular 2';
    skills = ['MVC 5', 'Angular 2', 'TypeScript', 'Visual Studio 2015'];
    myskills = this.skills[1];
}

test.component.ts

import { Component } from '@angular/core';

@Component({
    selector: 'fa-test',
    templateUrl: './test.component.html',
    styleUrls: ['./test.component.css']
})
export class TestComponent {
}

错误图片

Error

0 个答案:

没有答案