Sunday 15 July 2012

ember.js - why am i seeing "error while loading route" with ember? -


Amber RC1, Amber-Data Amendment 12. All my routes are loading correctly, unsure why I I am seeing this error when I try to use the show route ie. Corrected / files / groups / 5 index paths

I have pasted the stack trace below but it is not very informative

  this.resource ('files', {path: 'i / Files'}, function () {this.resource ( 'groups', {path: '/ groups'}, function () {this.route ( 'show', {path: '/: asset_link_group_id'});});}); AssetLinksApp.GroupsShowController = Ember.ArrayController.extend ({content: Ember.A (), assetLinkGroup: null}); AssetLinksApp.GroupsShowRoute = AssetLinksApp.AuthRequiredRoute.extend ({setupController: function (controller model) {controller.set ( 'content', model.get ( 'asset_links')); controller.set ( 'assetLinkGroup', model);} , Model: Functions (Parameters) {Return Assetlinks App. Asset Link Group. FIDD (Params.asset_link_great_id_id);}});   

Stack trace:

Error route loading: typos {} exchange_vendor.js: 12078

(Anonymous Ceremony) exchange_vendor .js: 12078 amber Rotor.openclass.filefileherhandler Setup exchange_windore JS: 35011 Failure exchange_videador. JS: 34448 Objects.Cake.Cantex Exchange_Window JS: 34497 Avoc Callback Exchange_Window JS: 17846 Promos. Then exchange_windore. JS: 17893 Event Target. Trigger exchange_viveador. JS: 17822 results exchange_windore. JS: 17 9 24 Run Loop Retrospective exchange_wevdor JS: 15 911 Amber Handeliers Exchange_Vender. JS: 12140 exchange exchange_viveador. JS: 15 9 9 ITAR Exchange _Windows JS: 15 9 81 runs loop.flish exchange_wonder. JS: 16035 runs loop Finally exchange_vendor.js: 15,940 tryable exchange_vendor.js: 16,143 Ember.tryFinally exchange_vendor.js: 12831 Ember.run.end exchange_vendor.js: 16146 Ember.tryFinally exchange_vendor.js: 12833 Ember.run exchange_vendor.js: 16102 Ember.HashLocation. Mberkobjekt.akstendkonupdteurl Akschenj_venderkjas: 36,690 JQuerykiventkdispac Akss Hnge_venderkjas: 3144 JQuerykiventkaed.alemdaatakhandl.aventndle

< Div class = "text" itemprop = "text">

The model returns a single record even though you have defined the ArrayController .

Ember.js automatically keeps the model in the property of the controller's content, causing the error to occur because it will maintain a record in an array of controllers.

Although you override the setupController , before it fires, amber.js will place the model in the controller anyway. Currently there is no way of stopping


update 3-Jun-2014 (amber> 1.0) :.

Now the override then setupController amber no longer sets the property model .


The only solution I can think is to add resources to our routes:

  This.resource ('files', {path:' / files'}, function () {this.resource ( 'groups', {path:' / groups'}, function () {this.resource ( 'group', {Path: '/: asset_link_group_id'}, function () {This.route ('index');});});});   

This means that you have an object controller ( GroupController ) group containing, and code an array controller (<> GroupIndexController ) with each link Array AssetLinksApp.GroupIndexController = Ember.ArrayController.extend ({assetLinkGroup: null}); AssetLinksApp.GroupIndexRoute = AssetLinksApp.AuthRequiredRoute.extend ({setupController: function (controller model) {Niyntrkkset ( 'content' model); Niyntrkkset ( 'AssetLinkGroup, ThiskmodelFor (' Group '));} , Model: functions (parameters) {return.modelfor ('group'). Get ('asset_links');}});

Your template should now be named group / index instead of groups / show . For the group template, this can be an empty template containing {{outlet}} .

This is worth noting that the most important thing: If your controller is an object controller, model hook object back , and if your controller array controller, you to return an array of model hook.

The bright side, it is better that pushes you to follow a certain design I might think of the core team.

No comments:

Post a Comment