javascript - Get current route name on handlebar template in Ember.js 2 -
i needed know current route name can show or hide global component created on application.hbs
.
this component should hidden in 1 route template, looks easier solution me. getting current route name , if equal "posts" not show header-bar
component.
something this:
{{#if currentroute != 'login'}} {{header-bar}} {{/if}} {{outlet}}
any idea on achieve or similar solves problem?
applicatiion
controller has property names currentroutename
. can use it.
if want use in template need define in controller.
test.js (controller)
init(){ this._super(...arguments); let appctrl = ember.getowner(this).lookup('controller:application'); this.set('appctrl', appctrl); }
test.hbs
{{appctrl.currentroutename}}
Comments
Post a Comment