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

Viewed 510

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

1 Answers

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.

Related