Last active
August 29, 2015 14:01
-
-
Save nooitaf/d24b1a562d0e89c6034f to your computer and use it in GitHub Desktop.
meteor map() index test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<title>maptest</title> | |
</head> | |
<body> | |
{{> hello}} | |
</body> | |
<template name="hello"> | |
{{#each posts}} | |
<li> | |
{{index}} {{title}} | |
</li> | |
{{/each}} | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
open browser console and do a few times..