請問一下目前要在某個component import一個ts裡面的class進來,但一直顯示我沒export,看官方範例也是這樣放進來滿單純的,但錯誤一直顯示我沒有export class出來。
這是component,目前問題是Recipesdata抓不到
import { Component, OnInit } from '@angular/core';
import { Recipesdata } from '../recipes.component';
@Component({
selector: 'app-recipes-list',
templateUrl: './recipes-list.component.html',
styleUrls: ['./recipes-list.component.scss']
})
export class RecipesListComponent implements OnInit {
// recipes: Recipesdata[] = [
// new Recipesdata('a','b','v')
// ]
constructor() { }
ngOnInit() {
}
}
滑鼠放在Recipesdata上vscode會顯示:
[ts] 'Recipesdata' 已宣告但從未讀取其值。
[ts] 模組 '"省略我的路徑/src/app/recipes/recipes.component"' 沒有匯出的成員 'Recipesdata'。
import Recipesdata
這是要import的model../recipes.component
路徑是沒有錯的,測過路徑
export class Recipesdata{
public name:string;
public description:string;
public imagePath:string;
constructor(name:string,desc:string,imagePath:string){
this.name = name;
this.description = desc;
this.imagePath = imagePath;
}
}
跑來來顯示錯誤:ERROR in src/app/recipes/recipes-list/recipes-list.component.ts(2,10): error TS2305: Module '"省略我的路徑/src/app/recipes/recipes.component"' has no exported member 'Recipesdata'.