1
我有这个接口和这个类:与打字稿得到JSON和角
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 method.Maybe我的课是错写。你能帮我吗? Thnaks!
我收到一个json是这样的:[对象,对象,对象,对象,对象,对象,对象,对象,对象,对象,对象,对象,对象,对象,对象,目标,对象] 0:对象 年龄: “5-6岁” AvailableForAdoption:真 颜色: “棕色” 历史: “遗弃所有者” LDAdoption:真 名称: “凯蒂” SpecialCare:真 类型: “猫” 特色:真 IMAGEURL: “IMG/photo_latest14.jpg” 最新:真 __proto__:对象 –
和一个错误:类型错误:无法设置属性“宠物'未定义 –
对不起,您必须更改注入属性:'petsCtrl。$ inject = ['$ http','$ scope'];'(我更新代码) –