0
所以我有這個類在一個單獨的文件中:如何使用導出類的Angular2組件
export class MyModel {
votes: number;
title: string;
link: string;
constructor() {
this.title = 'Github';
///
}
myfunc()
///
}
而且我想用它的道具在這個組件,但無法弄清楚如何要做到這一點:
import { Component } from '@angular/core';
import { MyModel } from './models.model';
@Component({
selector: ///
templateUrl: ///
styleUrls: ///
})
export class SomeComponent {
//declare somehow..?
}
你可以聲明其爲'讓MyObj中=新爲MyModel()'裏面你'SomeComponent'; – ranakrunal9