mardi 23 juin 2020

Ember 3+ passing action from component to controller not working

We have recently shifted from ember 2+ to Ember 3.18.0 and i am struggling to call the controller function from a component. In previous version we were using sendAction to bubble the action but now as sendAction is depreciated and closures are being used i am not able to make it correctly.

Below is my code

Controller.hbs


Controller.js

@action
closePromptDialog(){
    this.set("showErrorModal",false);
}

Component.hbs

    
  <PaperDialog id="genericModal" class="flex-50" @fullscreen= @onClose= @origin=>
      <PaperDialogContent class="text-align-center">
          
      </PaperDialogContent>
      <PaperDialogContent>
        <h2></h2>
      </PaperDialogContent>

      <PaperDialogActions @class="layout-row">
        <span class="flex"></span>
        <PaperButton @primary=true @onClick= @raised=true>Ok</PaperButton>
      </PaperDialogActions>

  </PaperDialog>

Component.js

@action
hideModal(){
    this.args.onSave();
}

on this i am getting error as

Uncaught TypeError: method is not a function

Any help will be very much appreciated.

Ember version i am using is 3.18.0




Aucun commentaire:

Enregistrer un commentaire