2017-07-03 70 views
0

我有一个示例mvc5项目,我在这个项目上成功使用了我的第一个角度2模块。现在我想在我的mvc区域内创建新的模块。所以我在我的区域解决方案中创建了一个名为app.components.ts文件的新区域!像你见下文:如何在mvc5区域使用angular2?

import { Component } from '@angular/core'; 
@Component({ 
    selector: 'area-app', 
    template:`<p>imanArea</p>` 
}) 
export class areacomponent {<<bring below error!!!!!!!!!!! 
    name = 'dd'; 
} 

装修人员的实验性支持是一种功能 是在将来的版本中改变。设置 'experimentaldecorators' 选项删除此警告

和第二个是我的根项目rootproj/app/app.module.ts

import { NgModule }  from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 
import { FormsModule } from '@angular/forms'; // <-- NgModel lives here 

import { AppComponent } from './app.component'; 
***below error for this line*** 
import { AreaAppComponent } from './Areas/SampleArea/app/app.areacomponent' 

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

找不到模块 './地区/ SampleArea /应用/ app.areacomponent'

我检查了我的路径和文件名!每一件事都是对的,但它并没有找到我的道路!

更多信息,我不得不说我的所有必要文件角在我的根项目,我的app.module是一个命名的文件夹内应用

表示:rootProj /应用/ app.module和rootProj/app/app.component.spec

是否可以在一个项目中同时使用angular2mvc-Area?我没有找到任何关于此的消息。

回答

1

实际上我用的WebAPI使用角2

返回和前端都将是在不同的项目文件夹。你会和平静的服务一起工作。

enter image description here