我刚刚开始使用ember,并开始使用一个ember.js应用程序,该应用程序从一个运行JSON REST API插件的Wordpress博客加载它的数据存储.
API的命名空间为"wp-json.php",并使用这些约定.
问题一:
我Error while loading route尝试设置DS.RESTAdapter并加载模型后出现错误.
问题二:
我正在尝试传递标题"type": "custom_post_type_slug",以获取自定义帖子类型的数据,并且无法使其工作.
这是我的代码:
App = Ember.Application.create({ }); //Create App
//Router
App.Router.map(function () {
this.resource('posts', {path: '/'}, function() {
this.resource('post', { path: ':post_id' } );
});
}); //End Router
//Posts Route
App.PostsRoute = Ember.Route.extend({
model: function(){
return this.store.find('post');
},
});
//Data
App.Post = DS.Model.extend({
title : DS.attr('string'),
});
App.PostAdapter = DS.RESTAdapter.extend({
host: 'http://example.com',
namespace: 'wp-json.php'
});
DS.RESTAdapter.reopen({
headers: {
"type": "custom_post_type_slug" …Run Code Online (Sandbox Code Playgroud)