Skip to content

Instantly share code, notes, and snippets.

@jeshan
Last active August 29, 2015 14:15
Show Gist options
  • Save jeshan/867401cae1692942cefa to your computer and use it in GitHub Desktop.
Save jeshan/867401cae1692942cefa to your computer and use it in GitHub Desktop.
angular-intro-03; ng-bind and ng-model example with function
<!DOCTYPE html>
<html ng-app='angularApp'>
<head>
<meta name="description" content="angular-intro-03; ng-bind and ng-model example with function">
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<script src="script.js">
</script>
<meta charset="utf-8">
</head>
<body ng-controller='MainController'>
<p>Gross price: <input ng-model='price'/></p>
<p>Tax: <input ng-model='taxPercentage' /></p>
<p>Total price: <span ng-bind='total()'></span></p>
</body>
</html>
var module = angular.module('angularApp', [ ]);
module.controller('MainController', function($scope) {
$scope.price = 10;
$scope.taxPercentage = 15;
$scope.total = function () {
return $scope.price * $scope.taxPercentage;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment