chris_1a3
chris_1a3

Reputation: 59

Pass property to component and then used it as conditional (ember js)

application controller

isHotel_profile: function (){
    return this.get('currentPath') === 'hotel';
}.property('currentPath'),

component

{{#step-controller hotelPage=isHotel_profile}} {{/step-controller}}

and here's the component template

{{#if hotelPage}}
 hotel page 
{{else}}
 not hotel page
{{/if}}

i want to use the property as conditional how can i achieve that

Upvotes: 1

Views: 621

Answers (1)

Your code is valid and should work fine.

Here's a demo: http://emberjs.jsbin.com/nesete/1/edit?html,js,output

Note that you can simplify your computed property like this:

isHotel_profile: Ember.computed.equal('currentPath', 'hotel')

Upvotes: 2

Related Questions