Oliver Zeigermann / @DJCordhose
Online Version: http://bit.ly/1EicQwV
Copyright 2015, Oliver Zeigermann
Copyright 2015, Oliver Zeigermann
Copyright 2015, Oliver Zeigermann
Copyright 2015, Mike North (@michaellnorth), https://twitter.com/ModernWebUI/status/575532649948790784/photo/1
https://www.google.com/trends/
https://www.google.com/trends/
<form>
<input name="greeting" value="{{greeting}}">
<p>{{greeting}}, World</p>
<a href="/?greeting=">Clear</a>
<input type="submit" value="Send">
</form>
var server = new Hapi.Server();
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
reply.view('index', { greeting: request.query.greeting || 'Hello' });
}
});
Run: node index.js
<input id="in">
<p><span id="log"></span>, World</p>
<input id="btn" type="button" value="Clear">
<script>
var model;
function setModel(value) {
model = value;
$("#log").html(model);
$("#in").val(model);
}
$(document).ready(function () {
$("#in").on("keyup", function (event) {
setModel($("#in").val());
});
$("#btn").on("click", function () {
setModel("");
});
setModel("Hello");
});
</script>
Run
(new HelloView({
model: new Model(),
el: '#example'
})).render();
Run
var Model = Backbone.Model.extend({
defaults: {
greeting: 'Hello'
}
});
var HelloView = Marionette.ItemView.extend({
events: {
'click #btn': 'onBtnClick'
},
bindings: {
'#in': 'greeting',
'#out': 'greeting'
},
onBtnClick: function () {
this.model.set('greeting', '');
},
onRender: function () {
this.stickit(); // sets 2-way bindings
},
template: _.template(', World
' +
'')
});
<body np-app ng-controller="HelloController as helloController">
<input ng-model="helloController.greeting.text">
<p>{{helloController.greeting.text}}, World!</p>
<input type="button" value="Clear" ng-click="helloController.clear()">
</body>
function HelloController() {
this.greeting = {
text: 'Hello'
};
}
HelloController.prototype.clear = function() {
this.greeting.text = '';
};
Run
@Component({
selector: 'hello-app'
})
@Template({
inline: `<input [value]="greeting" #in (keyup)="updateModel(in.value)">
<p>{{greeting}}, World</p>
<button (click)="reset(in)">Clear</button>`
})
class HelloCmp {
greeting: string;
constructor() {
this.greeting = 'Hello';
}
reset(input) {
this.greeting = '';
input.focus();
}
updateModel(value) {
this.greeting = value;
}
}
class HelloMessage extends React.Component {
constructor(props) {
super(props);
this.state = {greeting: this.props.greeting};
}
updateModel(event) {
this.setState({greeting: event.target.value});
}
reset() {
this.setState({greeting: ""});
}
render() {
return (
{this.state.greeting}, World
);
}
}
var mountNode = document.getElementById('example');
React.render(<HelloMessage greeting="Hello" />, mountNode);
Run
Oliver Zeigermann / @DJCordhose
Copyright 2015, Oliver Zeigermann