Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection iteration #112

Open
pro100sanya opened this issue Oct 24, 2013 · 1 comment
Open

Collection iteration #112

pro100sanya opened this issue Oct 24, 2013 · 1 comment

Comments

@pro100sanya
Copy link

Hello, could you give full example for noob,
how to iterate over collection?

With html template and data and binding.
I am trying to bind values, but cannot get it work.

Thanks.

@davidamitchell
Copy link

have a look at the below:

var plates = require('plates');

var markup = '<div data-bind="id"></div><div data-bind="name"></div>';
var data = [
    {
        id:'1',
        name:'bob'
    },
    {
        id:'2',
        name:'sue'
    },
    {
        id:'3',
        name:'sam'
    },
    {   
        id:'4',
        name:'joe'
    }
]

console.log(plates.bind(markup, data));

the output will be:

<div data-bind="id">1</div>
<div data-bind="name">bob</div>
<div data-bind="id">2</div>
<div data-bind="name">sue</div>
<div data-bind="id">3</div>
<div data-bind="name">sam</div>
<div data-bind="id">4</div>
<div data-bind="name">joe</div>

see also https://github.com/flatiron/plates/tree/master/test specifically

let me know if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants