Aswath
Aswath

Reputation: 106

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

Upvotes: 3

Views: 706

Answers (1)

Gennady Dogaev
Gennady Dogaev

Reputation: 5991

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.

Upvotes: 4

Related Questions