当在界面中包含另一个接口定义时,我在尝试在角度2中编写特定接口时遇到问题。见下文
posting.ts
interface Coordinate {
lng: number;
lat: number;
}
export interface Posting {
title: string;
thumbnailUrl:string;
price: number;
hasPrivateBedroom: boolean;
hasPrivateWashroom: boolean;
posterGender: string;
roommateGender: string;
coordinate: Coordinate;
}
在 posting.service.ts 中使用的界面
import { Injectable } from '@angular/core';
import { Posting } from './posting';
@Injectable()
export class PostingService {
getPostings(filter?: object): Posting[] {
return [
{thumbnailUrl: "http://placehold.it/3500x1500", price: 1200, title: "Bachelor pad with a playboy", hasPrivateBedroom: true, hasPrivateWashroom: false, posterGender: "male", roommateGender: "male", coordinate: {lng: -79.36, lat: 43.65} },
{thumbnailUrl: "http://placehold.it/3500x1500", price: 1200, title: "Bachelor pad with a playboy", hasPrivateBedroom: true, hasPrivateWashroom: false, posterGender: "male", roommateGender: "male", coordinate: {lng: -79.36, lat: 43.65} },
];
}
constructor() { }
}