Reputation: 1791
Am trying to fetch and display the items from my collection. I created the template and gave it the design for each item. Here is the code:
<template name="list_products">
{{#each applications}}
<div class="col-sm-4 col-lg-4 col-md-4">
<div class="thumbnail">
<img src="http://placehold.it/320x150" alt="">
<div class="caption">
<h4 class="pull-right">{{price}}</h4>
<h4><a href="#">{{title}}</a>
</h4>
<p>{{description}}</p>
</div>
</div>
</div>
{{/each}}
</template>
on the .js file, i created the applications that will return all the items in the collection
Template.list_products.applications = function(){
Products.find();
}
then i called the template in the .html file
{{> list_products}}
I got this error once i run "npm run start"
Refused to execute script from 'http://localhost:3000/js/jquery.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled
what am i doing wrong? any steps am missing here?
Upvotes: 0
Views: 77
Reputation: 1476
Do it by using a helper.
Template.list_products.helpers({
applications:function(){
return Products.find({});
}
});
Again you could iterate through the applications because it will return a cursor. It is possible also to return Products.find({}).fetch();
But first try with the cursor in order to see if it works.
Upvotes: 1