Ragu N S
Ragu N S

Reputation: 17

EmberJS - Unable to get parameters from action

I have problem in getting parameter values in action. If I try it in controller I am getting only null or undefined.

Here is my Template
<button  {{action  "select" this someParameter   target=controller on="doubleClick"}} >OK </button>

Here is my Controller

App.SampleController = Ember.Controller.extend({
    actions: {
        select: function(param1) { 
                alert("clicked"+param1);
            console.log(param1);
        },     
    }
});

Upvotes: 0

Views: 57

Answers (1)

Ajey
Ajey

Reputation: 8202

Use this -

App.SampleController = Ember.ObjectController.extend({
actions: {
    select: function(param1, param2) {
        alert("clicked "+param1 + param2);
        console.log(param1, param2);
    }
}

});

you should use ObjectController

And in the HTML -

<button  {{action  "select" this "someParameter"   target=controller on="doubleClick"}} >OK </button> 

DEMO - FIDDLE

Upvotes: 1

Related Questions