2016-04-21 42 views
0

在我的流星应用程序中,我想选择性地访问我的页面中的值。能够访问流星帮助程序的特定值

if (Meteor.isClient) { 

    var percentageData = [ 
    { 
     percent_type : 'online', 
     percentage: '20' 
    }, 
    { 
     percent_type : 'offline', 
     percentage: '55' 
    } 
    ]; 

    Template.authenticated_user.helpers({ 
    percentInformation: percentageData 
    }) 
} 

在这里,我返回一个简单的JSON到我的模板。

<template name="authenticated_user"> 

</template> 

我想要的是能够放置在这个JSON的页面部分在不同的地方。

例如:

<div id = {{percentInformation[0].percent_type}}></div>到ID分配到 '在线'。

这可能吗?

回答

0

这是可能的,唯一需要注意的是,你用点符号数组成员,以及:

{{percentInformation.[0].percent_type}}