Created
November 20, 2017 04:44
-
-
Save rsyring/fbb54bb2f4b5bdf6cce892ee6a8fae32 to your computer and use it in GitHub Desktop.
Mithril Contacts
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
function Contacts(vn) { | |
let contacts = [ | |
{name: 'Fred', email: '[email protected]'}, | |
{name: 'Bob', email: '[email protected]'}, | |
] | |
function addContact(contact) { | |
contacts.push(contact) | |
} | |
function delContact(email) { | |
// PROBLEM HERE | |
contacts = contacts.filter((el) => el.email !== email); | |
} | |
return { | |
view: function() { | |
return m("main", [ | |
m(ContactForm, {addContact: addContact}), | |
m(ContactList, {contacts: contacts, delContact: delContact}), | |
]) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment