Skip to content

Instantly share code, notes, and snippets.

@nooitaf
Last active August 29, 2015 14:01
Show Gist options
  • Save nooitaf/d24b1a562d0e89c6034f to your computer and use it in GitHub Desktop.
Save nooitaf/d24b1a562d0e89c6034f to your computer and use it in GitHub Desktop.
meteor map() index test
<head>
<title>maptest</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
{{#each posts}}
<li>
{{index}} {{title}}
</li>
{{/each}}
</template>
Posts = new Meteor.Collection('posts');
if (Meteor.isClient) {
Template.hello.posts = function(){
var i = 0;
return Posts.find({}).map(function(post){
post.index = i;
i += 1;
return post;
});
}
}
@nooitaf
Copy link
Author

nooitaf commented May 10, 2014

open browser console and do a few times..

Posts.insert({title:'something'});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment