2016-05-31 1 views
0

엠버 - 신기루와 협력 동일하지 않은,하지만 내 computed.equal가 작동하지 않습니다. 현재 데이터베이스가 연결되어 있지 않으므로 ember-mirage를 사용하여 데이터를 가짜로 만듭니다. if 문을 제거하면 제품이 페이지에 표시되지만 if 문을 추가 할 때 어떤 이유로 인해 제품이 표시되지 않습니다. 미리 감사드립니다.엠버 내가 두 가지 범주, 간식 및 공유로 제품을 분할하기 위해 노력하고있어

products.hbs

<div class='container'> 
     {{#each model as |product|}} 
      {{#if product.isSnack}} 
       <div class='col-md-4'> 
        <img src="{{product.image}}"> 
        <h3>{{product.name}}</h3> 
        <p>{{product.description}}</p> 
        <h4>£{{product.price}}</h4> 
        <button type='button' class='btn btn-xs'>ADD TO BASKET</button> 
       </div> 
      {{/if}} 
     {{/each}} 
    </div> 

모델/product.js

export default Model.extend({ 

name: attr('string'), 
description: attr('string'), 
typeOf: attr('string'), 
price: attr('number'), 
image: attr('string'), 

isSnack: Ember.computed.equal('typeOf', 'snack'), 

isShare: Ember.computed.equal('typeOf', 'share') 

}); 

신기루/config.js

당신의 신기루 응답에서
this.get('/products', function() { 
    return { 
    data: [{ 
     type: 'products', 
     id:1, 
     attributes: { 
     name: "Mediterranean Snack Pop's", 
     typeOf: 'snack', 
     description: '', 
     price: 0.80, 
     image: '' 
     } 
    }, { 
     type: 'products', 
     id:2, 
     attributes: { 
     name: "Spicy Snack Pop's", 
     typeOf: 'share', 
     description: '', 
     price: 0.80, 
     image: '' 
     } 
    } 
    }] 
}; 
}); 

답변

1

, 그렇게, dasherized 값을 사용한다 즉 { type: 'products', id:2, attributes: { name: "Spicy Snack Pop's", 'type-of': 'share', description: '', price: 0.80, image: '' }

+0

직업에 감사했습니다. – d9nny