Bind Form to scope
Description
The following code shows how to Bind Form to scope.
Example
<!DOCTYPE html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
var MedicationCtrl = function($scope) {
$scope.medication = {<!--from w ww .ja v a2 s. c o m-->
dosage : 0.5,
count : 10,
total : function() {
return this.dosage * this.count;
}
};
}
</script>
</head>
<body>
<div ng-app ng-controller="MedicationCtrl">
dosage : <input type="number" ng-model="medication.dosage"><br>
count : <input type="number" ng-model="medication.count">
<hr>
Total: {{medication.total()}}
</div>
</body>
</html>