Quick Angular Binding Example
HTML
<div ng-app ng-controller="Controller">
<input type="text" ng-model="obj.first">{{obj.first}}
<input type="text" ng-model="obj.last">{{obj.last}}
<input type="checkbox" ng-model="obj.subscribed">{{obj.subscribed}}
<input type="button" value="Submit Object" ng-click="submit()">
</div>
CSS
div {
margin: 20px;
}
div input {
display: block;
margin-top: 20px;
}
JavaScript
function Controller($scope) {
// This comes from the server
$scope.obj = {
first: 'John',
last: 'Smith',
subscribed: true
};
// All changes should be reflected
$scope.submit = function() {
console.log('Object: ');
console.log($scope.obj);
}
}