【发布时间】:2016-03-30 21:10:14
【问题描述】:
我有这个接口和这个类:
module AnimalPlanet{
export interface Pet {
Type: string;
Name: string;
Age: string;
Color: string;
SpecialCare: boolean;
AvailableForAdoption: boolean;
LDAdoption: boolean;
History?: string;
featured: boolean;
newest: boolean;
imageUrl: string;
type: string;
name: string;
}
export interface RootObject {
pets: Pet[];
}
export class petsCtrl {
dataFromServer : RootObject;
constructor(private $http: ng.IHttpService) {
this.$http.get('/app/pets/pets.json').then(function(response){
console.log(response.data);
return response.data;
});
}
}
petsCtrl.$inject = ['$http'];
app.controller("petsCtrl", petsCtrl);
}
我尝试在视图中显示一些数据,但某些内容不适用于我的 get 方法。也许我的课程写错了。你能帮我吗?谢谢!
【问题讨论】:
标签: angularjs json typescript