簡體   English   中英

Ember.js和PHP API

[英]Ember.js and PHP API

我目前在學習Ember的基礎知識以及如何與后端服務通信方面遇到問題。

這是我在router.js所做的router.js

Rugby.RugbyRosterRoute = Ember.Route.extend({
        model: function(){

            return [{

                    firstname:$.getJSON("/RugbyAPI")
                    // $.getJSON("/RugbyAPI") returns "John"

                }];

            //return this.store.find('roster');
        },

        renderTemplate: function(controller) {
            this.render('rugby/roster', {controller: controller});
            // tried this as well
            //this.render('rugby/roster', controller);

        }
    });

但這就是渲染的內容。... [object Object]

我想我的問題是我將如何處理這個“對象”。 我過去一天一直被困住,但現在好運...

編輯:

我在網絡瀏覽器控制台中運行此命令...

$.getJSON("/RugbyAPI", function(data) { console.log(data) });       

結果如下:

-> Object {readyState: 1, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function…}
-> John

我的猜測是我必須解析我需要顯示的鍵...但是我似乎無法解析它。... ['responseJSON']['firstname']等,什么都沒有用...

{controller: controller}

是一個對象。

嘗試:

this.render('rugby/roster', controller);

要么:

this.render('rugby/roster', controller.propertyName);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM