jeudi 15 août 2019

EmberJS - Assertion Failed: computed expects a function or an object as last argument

Trying to use ember-models-table 3.x but facing an issue with "Assertion Failed: computed expects a function or an object as last argument."

ember-cli: 3.9.0

node: 10.16.1

Create a brand new ember project and updated the files below,

routes/test.js

import Route from '@ember/routing/route';
import {A} from '@ember/array';

export default Route.extend({
  setupController(controller) {
    controller.set('columns', A([
      { propertyName: 'index' },
      { propertyName: 'firstName' },
      { propertyName: 'lastName' },
      { propertyName: 'age' },
      { propertyName: 'city' }
    ]));
    controller.set('data', A({
      data: [
        { id: 1, type: 'movies', attributes: { name: 'Interstellar' } },
        { id: 2, type: 'movies', attributes: { name: 'Inception' } },
        { id: 3, type: 'movies', attributes: { name: 'Dunkirk' } },
      ]
    }));
  }
});

templates/test.hbs

<ModelsTable @data= @columns= />

router.js

import EmberRouter from '@ember/routing/router';
import config from './config/environment';

const Router = EmberRouter.extend({
  location: config.locationType,
  rootURL: config.rootURL
});

Router.map(function() {
  this.route('test');
});

export default Router;

Error

index.js:163 Uncaught Error: Assertion Failed: computed expects a function or an object as last argument.
    at assert (index.js:163)
    at new ComputedProperty (metal.js:2757)
    at computed (metal.js:3220)
    at Module.callback (models-table.js:192)
    at Module.exports (loader.js:106)
    at Module._reify (loader.js:143)
    at Module.reify (loader.js:130)
    at Module.exports (loader.js:104)
    at requireModule (loader.js:27)
    at Class._extractDefaultExport (index.js:426)




Aucun commentaire:

Enregistrer un commentaire