mercredi 28 décembre 2016

Create base class for controller to extend in Ember application

I'm trying to create a Base Class for my controllers, so I can avoid duplication of code.

The problem here is that it is throwing me errors whenever I try to use it.

"Assertion Failed: You attempted to define a but did not pass the parameters required for generating its dynamic segments. Could not find module controllers/base-inventory imported from frontend/controllers/inventory"

To create my base controller I am using ember cli and this is what I did:

ember g controller base-inventory

Then

// base-inventory.js
const BaseInventory = Ember.Controller.extend({
   //my code...
});
export default BaseInventory;

In the controller where I want to use this base class I did the following

import BaseInventory from 'controllers/base-inventory';
// also tried import { BaseInventory } from 'controllers/base-inventory';
// and  export default new BaseInventory({});
export default BaseInventory.extend({
    //more code here...
});

Any thoughts of what I am doing wrong? I didn't plan to use mixins, because it doesn't seem the best option here, but if it's not possible to do the way I'm trying to, I'll write a mixin.




Aucun commentaire:

Enregistrer un commentaire