mardi 18 juillet 2017

Ember js use of variable from controller to hbs file

I am new to emberjs. I have a button , I want to disable that button on the basis of some value. I have a two controllers, I am calling a method from controller A which is of controller B. So, That I can use that variable in the hbs file. So, my code is like -

controller A-

    App.controllerA = Ember.ObjectController.extend({
        needs: ['searchResult'],
        isrequestFromApplicationVar: undefined,
  actions: {
           isrequestFromApplication: function() {
             isrequestFromApplicationVar = true;
             console.log("======================>" +isrequestFromApplicationVar);
        },

        SetisrequestFromApplication: function() {
            isrequestFromApplicationVar = null;
            console.log("in the else xof the function====>" +isrequestFromApplicationVar);
        },
           }

controller B

App.controllerB = Ember.ArrayController.extend({
    needs:['controllerA'],
    actions: {
    searchvalue: function(query) {
            var self = this; // use this inside ajax request
            var value =  location.search.split('userName=')[1];
            if(value) {
                this.get('controllers.controllerA').send('isrequestFromApplication');
            } else {
                this.get('controllers.controllerA').send('SetisrequestFromApplication');
            }
}
}

So, from here I am able to call the methods as well.

Move To corpus

This is my hbs file content, I want to disable this button. So, I am not able to use that value in the hbs file ? can any one please help me with this?




Aucun commentaire:

Enregistrer un commentaire