ember.js

LinkTo fails on click


I generate a link as:

<td><LinkTo @route="assets.asset" @model="{{asset.id}}">{{asset.id}}</LinkTo></td>

The link is generated correctly. When I click nothing happens. The inspector shows an error like:

Error while computing: arguments
Error while computing: caller

My routes are:

Router.map(function () {
  this.route('assets', function(){
    this.route('asset', { path: '/:id' });
  });
});

assets route hanldler:

import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class AssetsRoute extends Route {
  @service store;
  async model() {
    return this.store.findAll('asset');
  }
}

asset handler looks like:

import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class AssetRoute extends Route {
  @service store;
  async model(params) {
    return this.store.findRecord('asset', params.id);
  }
}

enter image description here

Any suggestion?


Solution

  • I don't think you should have quotes around the @model variable. This happens to me quite a bit because Visual Studio Code "helpfully" adds them as I'm typing. Try this instead:

    <td><LinkTo @route="assets.asset" @model={{asset.id}}>{{asset.id}}</LinkTo></td>