Search code examples
ember.jsmodelcontrollerember-cliquery-string

How to pass properties from One controller to another in ember without involving route's setupController?


How to pass properties from One controller to another in ember without involving route's setupController


Solution

  • In simplest cases you can inject one controller into another:

    // app/controllers/signup.js
    
    import Controller, { inject as controller } from '@ember/controller';
    
    export default Controller.extend({
      login: controller('login'),
    
      signup() {
        // Do some requests to create new user
    
        // And then set properties on login controller
        this.login.set('formData', {
          email: this.get('formData.email'),
          password: this.get('formData.password'),
        });
      }
    });
    

    For something more complex, services are good.