내 MEEN 스택 응용 프로그램에 모듈 로깅 오류가 있습니다. 몽구스를 통해 익스프레스 서버에서 데이터를 가져 오는 엠버 루트 모델이 있습니다.Ember 모델 계산 된 속성이 작동하지 않습니다.
내 모델에서 날짜 속성을 변경하여 페이지에 부동산을 저장하기 위해 mongo 데이터베이스에 저장되는 방식과 다르게 날짜를 형식화하고 싶습니다. Tue Sep 19 2017 16:57:17 GMT-0400 (EDT)에서 2017-09-19.
모델의 컴퓨터 속성에 대한 Ember 문서를 추적했지만 템플릿에 계산 된 값이 표시되지 않습니다.
모델 :
import DS from 'ember-data';
import Ember from 'Ember';
export default DS.Model.extend({
error: DS.attr('string'),
user: DS.attr('string'),
module: DS.attr('string'),
date: DS.attr('string'),
smallDate: Ember.computed('date', function() {
var dateObj = new Date(this.get('date'));
return `${dateObj.getFullYear()}-${dateObj.getMonth()}-${dateObj.getDate()}`;
})
});
템플릿 :
<div class="row">
<div class="col-md-8 col-md-offset-2 text-center">
<h2 class="toolTitle">Blame Panel</h2>
</div>
</div>
<div class="col-md-8 col-md-offset-2">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>User</th>
<th>Error</th>
<th>Component</th>
<th>Date</th>
</tr>
</thead>
<tbody>
{{#each model as |blame index|}}
<tr>
<th scope="row">{{index}}</th>
<td>{{blame.user}}</td>
<td>{{blame.error}}</td>
<td>{{blame.module}}</td>
<td>{{blame.smallDate}}</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
난 그냥이 포맷되지 않은 날짜 벌금을 표시하는 모델의 날짜 속성을 사용합니다.
을 난 그냥 모든 템플릿에 더 리턴 값을 받고 없습니다 있어요. 나는 엠버 조사관을 확인했고 그 자산은 모델에 전혀 나타나지 않았다. –
단위 테스트에서 물건을 테스트 할 것을 제안합니다 (도우미 접근법 또는 모델). 나는이 버그를 추적하는 데 정말로 도움이된다. 디버거 문을 추가하면 도움이된다. – acorncom
조언을 주셔서 감사합니다. 유닛 테스트를 해보십시오. 버그가 없으면 끝내 버리겠습니다. 이제 알아 내라. –