简体   繁体   中英

EmberJS : “Uncaught Error: More context objects were passed than there are dynamic segments for the route”

I have two routes of which one of them uses a dynamic segment :

App.Router.map(function() {
    this.resource('books');
    this.resource('book', {
        path: "/book/:book_uid"
    })
});

When i try the helper {{link-to 'book' abook.uid}} in the Books template, I get the error :

Uncaught Error: More context objects were passed than there are dynamic segments for the route: book

This is the model for Book :

App.Book = DS.Model.extend({
    book_id: DS.attr()      
});

and this is how i define the route for Book :

 App.BookRoute = Ember.Route.extend({
            model: function(params) {
                return this.store.find('book', params.book_uid);
            },
            serialize: function(model) {
                return {
                    book_uid: model.get('uid')
                };
            } 
});

Any ember saints out there who can give a look see???

When the link-to helper is used in inline form the first parameter is used as the link text and the remaining args as your route path.

So you in your case you have to pass three args to it like this:

{{link-to 'Show book' 'book' abook.uid}}

Or use the block form in this way:

{{#link-to 'book' abook.uid}}
  Show book
{{/link-to}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM