我是一个初学者在Ember.js,我想得到一个响应结果,并显示在我的视图(超文本标记语言)。
我的结果是:
{"teste": { "code": "1", "message": "hello" } }我在Ember.js中的控制器:
actions: {
discountCoupon: function() {
var lista = _this.store.find('teste', { "param": "123" });
console.info("return=" + lista.get('code'));
// result return===undefined
console.info("return===" + lista.get('message'));
// result return===undefined
},
...
}我的模型:
import DS from 'ember-data';
export default DS.Model.extend({
code: DS.attr('string'),
message: DS.attr('string'),
});我不能得到我的后端的回报。
提前谢谢。
发布于 2016-08-19 23:15:11
还有一件事,因为您正在使用Ember数据并尝试使用store.find('model', { queryParams })搜索Ember,所以Ember希望后端返回复数形式的结果:{"testes": [{"code":"1","message":"hello"}}]
发布于 2016-08-19 23:00:45
首先,你需要找到你一直在寻找的东西,然后你才能得到你的结果。记住,当javascript promise你的时候,一些东西总是会给你返回一个结果...
actions: {
discountCoupon: function(){
var listas = _this.store.find('testes', {
param: "123"
}).then(function(lista){
console.log("return=" + lista.get('code'));
console.log("return===" + lista.get('message'));
});
},https://stackoverflow.com/questions/39041927
复制相似问题