AngularJs - 在组件中导入模型抛出错误
AngularJs - Import Model in Component throwing error
我是初学者,遇到了障碍,需要一些快速帮助..
我收到的错误:[ts] 找不到模块'./../../../Models/Property'。将鼠标悬停在 import { 属性 } 行
上可以看到
在我的属性-form.component.ts
import { Component, OnInit } from '@angular/core';
import { Property } from './../../../Models/Property';
@Component({
selector: 'app-property-form',
templateUrl: './property-form.component.html',
styleUrls: ['./property-form.component.css']
})
export class PropertyFormComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
我的文件夹结构
ClientApp
|___ app
|___ components
|___ property-form
|___ property-form-component.css
|___ property-form-component.html
|___ property-form-component.ts
Models
|___ Property.cs
有人知道问题出在哪里吗?或者我该如何解决这个问题?
谢谢
您需要在导入时更上一层楼,如下所示:
import { Property } from '../../../../Models/Property';
使用 ../
,您处于 "components" 文件夹级别;
有../../
、"app"个文件夹;
有../../../
、"ClientApp"个文件夹;
使用 ../../../../
您终于进入了根文件夹,您可以从中转到 "Models"。
我是初学者,遇到了障碍,需要一些快速帮助..
我收到的错误:[ts] 找不到模块'./../../../Models/Property'。将鼠标悬停在 import { 属性 } 行
上可以看到在我的属性-form.component.ts
import { Component, OnInit } from '@angular/core';
import { Property } from './../../../Models/Property';
@Component({
selector: 'app-property-form',
templateUrl: './property-form.component.html',
styleUrls: ['./property-form.component.css']
})
export class PropertyFormComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
我的文件夹结构
ClientApp
|___ app
|___ components
|___ property-form
|___ property-form-component.css
|___ property-form-component.html
|___ property-form-component.ts
Models
|___ Property.cs
有人知道问题出在哪里吗?或者我该如何解决这个问题?
谢谢
您需要在导入时更上一层楼,如下所示:
import { Property } from '../../../../Models/Property';
使用 ../
,您处于 "components" 文件夹级别;
有../../
、"app"个文件夹;
有../../../
、"ClientApp"个文件夹;
使用 ../../../../
您终于进入了根文件夹,您可以从中转到 "Models"。