Data Binding with CommonJS Standard
River.js is a small framework focus on module enclosure and data binding,
borrows scope, directive ideas from AngulaJS but keep same style with node module definition.
borrows scope, directive ideas from AngulaJS but keep same style with node module definition.
1 <div scope>
2 <label for="">name:</label>
3 <input type="text" class="form-control" jbind="name">
4 <hr>
5 <p>Hello {{ name }} !</p>
6 <p>the {{ name }} ?</p>
7 <p>world {{ name }} !</p>
8 <p>and {{ name }} .</p>
9 </div>
Hello {{ name }}!
the {{ name }} ?
world {{ name }} !
and {{ name }} .
1 <div scope="your.firstpage.controller">
2 <p>{{ name }} </p>
3 <button jclick="changeName()">change the name</button>
4 </div>
1 //@sourcefile: your/firstpage/controller.js
2 exports.name = 'Jonathan';
3 exports.changeName = function(){
4 if('Jonathan' === exports.name){
5 exports.name = 'River';
6 }else{
7 exports.name = 'Jonathan';
8 }
9 }
1 //or
2 exports = module.exports = function(){
3 var scope = this;
4 scope.name = "Jonathan"
5
6 scope.changeName = function(){
7 if('Jonathan' === scope.name){
8 scope.name = 'River';
9 }else{
10 scope.name = 'Jonathan'
11 }
12 }
13 }
{{ name }}