Angular: Binding to selection
http://angularjs.org/
HTML
<script type="text/javascript" ng:autobind src="http://code.angularjs.org/0.10.6/angular-0.10.6.js"></script>
<div ng:app="MyApp" ng:controller="CtrlA">
<select ng:options="l.name for l in list" ng:model="selection" ng:change="sel()"></select>
<textarea type="list" ng:model="selection.values"></textarea>
Selection: {{selection.name}}
</div>
JavaScript
var appModule = angular.module('MyApp', []);
appModule.value('MyList', [{
name: 'test1',
values: ['a', 'b']},
{
name: 'test2',
values: ['c', 'd']
}]);
function CtrlA(MyList) {
this.list = MyList;
this.selection = MyList[0];
this.sel = function() {
console.log("meh");
}
}