Accessing Ember-CLI Nested Controllers

后端 未结 2 584
半阙折子戏
半阙折子戏 2021-01-28 06:30

This is my directory structure:

controllers/
---- restaurant/
    ----items.js
---- index.js
---- restaurant.js

And my router declaration:

2条回答
  •  一整个雨季
    2021-01-28 06:37

    As of Ember-CLI v0.2.1 + Ember v1.10.0 (could work for earlier versions; but I haven't tried), this is how you do it:

    export default Ember.ObjectController.extend({
        needs: ["restaurant/items"],
        ...
    

    To access actions, you'd do this:

    actions: {
        myAction: function(arg1, arg2) {
          this.get('controllers.restaurant/item').send('someItemActionYouDefine', arg1, arg2);
        }
    }
    

提交回复
热议问题