Ember.js external json for Store

∥☆過路亽.° 提交于 2019-12-13 20:07:19

问题


I have a json file that lives on the on the server that is hosting my Ember.js app. I want to use that json as the "store" for the app (it will only be for reading). I'm not sure the best way to do this. Do I need to use a RESTAdapter to hit the file, or somehow use it as an external FixtureAdapter, or is there some other way to accomplish this?


回答1:


Your best bet is to use the fixture adapter as described here. If the file is static, you can just add it to your page as a script tag and be done with it. If the file changes per user, you'll probably have to write some server-side logic to generate it. If that's the case, I would append it to your HTML file as a self executing function or something. Either way, if your data isn't changing, the FixtureAdapter is your best bet. You don't want to have to mess with the RESTAdapter or trying to write your own.



来源:https://stackoverflow.com/questions/17778364/ember-js-external-json-for-store

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!