How to enable query-params-new feature using ember-rails

我的未来我决定 提交于 2019-12-01 20:13:15

问题


I am having trouble using the query-params-new feature.

My version of ember is 1.4.0-beta.2.

Ember.js is loaded into my rails app through the ember-rails and ember-source gems.

Before initializing the Ember App I turn on the feature like so.

Ember.FEATURES["query-params-new"] = true

After doing so I get the following error when navigating to any route.

Error while loading route: TypeError: Object [object Object] has no method 'paramsFor' at Ember.Route.Ember.Object.extend.deserialize

Am I missing something? Do I need to define a paramsFor method at each route?


回答1:


I'm having the same problem, I noticed this issue mentioning the problem, and attributes it to misusing the new query params API. Where you using the prior implementation?

Edit: My problem was how I was enabling it. I was following the prior method of simply passing a value to Ember.FEATURES:

Ember.FEATURES['query-params-new'] = true;

However, the docs now specify the correct method (which also needs to happen before the Ember js file is loaded by the browser):

ENV = {FEATURES: {'query-params-new': true}};



回答2:


I forgot coffee-script wraps everything in a top-level function.

Here is the way I do it in coffee-script.

#= require_self
#= require handlebars
#= require ember

@ENV = {FEATURES: {'query-params-new': true}} 


来源:https://stackoverflow.com/questions/21124590/how-to-enable-query-params-new-feature-using-ember-rails

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