Created
March 18, 2015 17:03
-
-
Save tinchoz49/3656c6a8c62b05a6e4bb to your computer and use it in GitHub Desktop.
components in mithril
This file contains hidden or 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
var app = {}, | |
buttonComponent = {}; | |
buttonComponent.controller = function ( options ) { | |
this.title = options.title; | |
}; | |
buttonComponent.view = function ( ctrl ) { | |
return m('button', 'The button component: ' + ctrl.title()); | |
}; | |
app.controller = function () { | |
this.title = m.prop('idea'); | |
}; | |
app.view = function ( ctrl ) { | |
return [ | |
m('h1', ctrl.title()), | |
m(buttonComponent, { title: ctrl.title }) | |
]; | |
}; | |
m.mount(document.getElementById('app'), app); // or maybe m.render |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment