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

Array access in m-for #62

Closed
nakome opened this issue Jun 1, 2017 · 4 comments
Closed

Array access in m-for #62

nakome opened this issue Jun 1, 2017 · 4 comments
Assignees
Labels
Milestone

Comments

@nakome
Copy link

nakome commented Jun 1, 2017

Hi, I have a question, how to access the title with m-for in this array ?

const app = new Moon({
    data: {
        users: {
            "id1": {
                "title": "vitae",
                "description": "Lorem ipsum dolor sit amet"
            },
            "id2": {
                "title": "vitae",
                "description": "Lorem ipsum dolor sit amet"
            },
            "id3": {
                "title": "vitae",
                "description": "Lorem ipsum dolor sit amet"
            }
        }
    }
});
@adekoyejoakinhanmi
Copy link
Contributor

You can do something like so:

  • {{user.title}} ....

P.S forgive the formatting. I replying from my phone.

@adekoyejoakinhanmi
Copy link
Contributor

'''html
ul
li m-for="user in users"
span {{user.title }}
'''

@kbrsh kbrsh self-assigned this Jun 1, 2017
@kbrsh kbrsh added the feature label Jun 1, 2017
@kbrsh kbrsh added this to the v0.11.0 milestone Jun 1, 2017
@kbrsh
Copy link
Owner

kbrsh commented Jun 1, 2017

You cannot iterate through objects with m-for (yet). I'll add this in v0.11.0, and you will be able to do:

<ul>
  <li m-for="user in users">{{user.title}}</li>
</ul>

@nakome
Copy link
Author

nakome commented Jun 1, 2017

Good, thx

@kbrsh kbrsh closed this as completed in e6ab77d Jun 1, 2017
kbrsh added a commit that referenced this issue Jun 8, 2017
…ays, objects, and numbers for 'm-for' (fixes #62)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants