接口中的Angular 2接口定义

时间:2017-04-21 04:43:37

标签: angular typescript interface

当在界面中包含另一个接口定义时,我在尝试在角度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() { }

}

以下是我收到的错误 Compilation Error

0 个答案:

没有答案