Merge remote-tracking branch 'origin/components' into components

This commit is contained in:
Leo Horie 2015-03-30 13:27:41 -04:00
commit 80437a0f23

View file

@ -61,12 +61,12 @@ Modules can have arguments "preloaded" into them. Calling `m.module` without a D
```javascript ```javascript
//declare a component //declare a component
var MyModule = {} var MyModule = {}
MyModule.controller = function(options, extras) { MyModule.controller = function(args, extras) {
this.greeting = "Hello" this.greeting = "Hello"
console.log(options.name, extras) console.log(args.name, extras)
} }
MyModule.view = function(ctrl, options, extras) { MyModule.view = function(ctrl, args, extras) {
return m("h1", ctrl.greeting + " " + options.name + " " + extras) return m("h1", ctrl.greeting + " " + args.name + " " + extras)
} }
@ -148,11 +148,11 @@ var TemperatureConverter = {
return (value 9 / 5 * (v - 273.15)) + 32 return (value 9 / 5 * (v - 273.15)) + 32
} }
}, },
view: function(ctrl, options) { view: function(ctrl, args) {
return m('div', [ return m('div', [
"celsius:", ctrl.kelvinToCelsius(options.value), "celsius:", ctrl.kelvinToCelsius(args.value),
m("br"), m("br"),
"fahrenheit:", ctrl.kelvinToFahrenheit(options.value), "fahrenheit:", ctrl.kelvinToFahrenheit(args.value),
]); ]);
} }
}; };
@ -329,7 +329,7 @@ var ContactsWidget = {
view: function(ctrl) { view: function(ctrl) {
return [ return [
m.module(ContactForm, {onsave: ctrl.save}), m.module(ContactForm, {onsave: ctrl.save}),
m.module(ContactList, {contacts: contacts}) m.module(ContactList, {contacts: ctrl.contacts})
] ]
} }
} }
@ -408,7 +408,7 @@ var ContactForm = {
Contact.save(contact) Contact.save(contact)
} }
}, },
view: function() { view: function(ctrl) {
var contact = ctrl.contact() var contact = ctrl.contact()
return m("form", [ return m("form", [
@ -494,7 +494,7 @@ var ContactForm = {
Contact.save(contact).then(Observable.trigger) Contact.save(contact).then(Observable.trigger)
} }
}, },
view: function() { view: function(ctrl) {
var contact = ctrl.contact() var contact = ctrl.contact()
return m("form", [ return m("form", [