Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to bind Application controller property in another controller ember

i have search property in ApplicationController and its linked with input field of searching. i want to access search field of ApplicationController in ProjectController. it should be sync. i use following code but its not working.

/ app/controllers/projects/index.js (project Controller)

import Ember from 'ember';
export default Ember.Controller.extend({
    needs: ['application'],
    searchBinding: 'controllers.application.search'
});

/ app/controllers/application.js (Application Controller)

  import Ember from 'ember';
    export default Ember.Controller.extend({
      search: ''
    )}

application.hbs

{{input value = search}}

like image 897
Muhammad Ateek Avatar asked Nov 28 '22 23:11

Muhammad Ateek


1 Answers

Ember needs is deprecated and is now used differently.

It works like this:

applicationController: Ember.inject.controller('application'),
mySearch: Ember.computed.alias('applicationController.search')

In your hbs template -

{{mySearch}}

 is in sync with applications property "search".

like image 126
kris Avatar answered Dec 11 '22 02:12

kris