Passing parameters from a deftjs controller to another

573 Views Asked by At

I'm using Deftjs´s ViewControllers, and now I had to pass some variables from a controller to another.

How is the best way, since I create a view and not a controller?

My actual solution is:

In controller 1:

var me = this;
var win = Ext.create('App.view.car.Window');
win.getController().setBrandId(me.brandId);
win.getController().setColorId(me.colorId);
win.show();

and my controller for car view:

Ext.define('App.controller.car.WindowController', {
    extend: 'Deft.mvc.ViewController',
    config: {
        brandId: null,
        colorId: null
    },
....

Thanks,

1

There are 1 best solutions below

0
hsd On

The solution for your question is like this:

var win = Ext.create('App.view.car.Window' {
    controllerConfig: {
        brandId: me.brandId,
        colorId: me.colorId    
});
win.show();

controllerConfig is section of configuration which is pass as normal config for controller.