2016-09-26 4 views
0
내가 HTML 페이지에서 객체의 배열을 표시 할

에서 객체의 배열을 인쇄, 그래서 나는이 한 :어떻게 유성 도우미

Template.home.helpers({ 
contents() { 
var contentArray = []; 
var content1 = 
{ 
'contentName': 'test1', 
'contentSize': 'test1', 
'contentType': 'test1', 
}; 
var content2 = 
{ 
'contentName': 'test2', 
'contentSize': 'test2', 
'contentType': 'test2', 
}; 
contentArray.push(content1); 
contentArray.push(content2); 
return contentArray; 
} 
}); 

가 어떻게 HTML 페이지의 "내용"을 표시 할 수 있습니까?

답변

1

유성 튜토리얼을 통해 작업 했습니까? 이는 두 번째 단계 인 here에서 다룹니다.

당신을 위해, 다음이 기본 모델로 충분합니다 :

<template name="home"> 

    {{#each thing in contents}} 
    <ul> 
     <li>Name: {{thing.contentName}}</li> 
     <li>Size: {{thing.contentSize}}</li> 
     <li>Type: {{thing.contentType}}</li> 
    </ul> 
    {{/each}} 

</template> 

을이 처음 블레이즈 튜토리얼의 처음 몇 단계를 통해 일하기 좋은 것이 이해가되지 않는 경우.

당신은 또한 특히, 불꽃 문서 살펴보고 #each ... in ... 할 수 있습니다 - 나는 문제가 해결

관련 문제