问题
i try to set a property of another controller via my click function.
click: function(event){
var controller = this.get('controller');
router.transitionTo('inc.index',this.content);
console.log(controller.hidden)
controller.set('hidden',false);
}
})
Therefore i set up my tableController with a hiddenbinding:
App.TableController = Em.ArrayController.extend({
needs: ['mainMenu'],
hidden:true,
hiddenBinding: 'controllers.mainMenu.isHidden'
})
App.MainMenuController= Em.Controller.extend({
isHidden: true
})
In my navbar the attribute 'isHidden' should change when 'hidden' in the tableController changes.
<script type="text/x-handlebars" data-template-name="mainMenu">
<nav>
<ul class="nav">
<li {{bindAttr class="isHidden:hidden"}}> {{#linkTo "incidents"}} Störfall {{/linkTo}}</li>
</ul>
</nav>
Unfortunatly the binding doesn't work and i dont know why. I tried to do it the same way as it was posted here earlier on but i guess i understood something wrong.
来源:https://stackoverflow.com/questions/15642077/accessing-other-controller-from-a-view