AngularJs - 组件抛出错误中的导入模型

时间:2017-10-03 12:06:29

标签: angular typescript angular-components

我是初学者,遇到了障碍,需要一些快速的帮助。

我收到的错误:[ts]无法找到模块'./../../../Models/Property'。通过将鼠标悬停在导入{Property}行

上可以看到它

在我的property-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

有谁知道这是什么问题?或者我如何解决这个问题?

谢谢

1 个答案:

答案 0 :(得分:0)

您需要再次升级导入,例如:

import { Property } from '../../../../Models/Property';

使用../,您处于“组件”文件夹级别;

使用../../,“app”文件夹;

使用../../../,“ClientApp”文件夹;

使用../../../../,您最终会在根文件夹中,您可以从中找到“模型”。