Skip to content

Instantly share code, notes, and snippets.

@ynonp
Created November 25, 2013 16:38
Show Gist options
  • Save ynonp/7644250 to your computer and use it in GitHub Desktop.
Save ynonp/7644250 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html ng-app="Intro">
<head>
<title>Hello Angular</title>
<style>
body {
font-size: 2em;
}
label {
margin: 2em;
}
input {
margin: 2em;
font-size: 16px;
}
</style>
</head>
<body>
<div ng-controller="Products">
<div>
<label>
Hats
<input ng-model="n_hats" />
</label>
</div>
<div>
<label>
Tables
<input ng-model="n_tables" />
</label>
</div>
<div>
<label>
iPhones
<input ng-model="n_iphones" />
</label>
</div>
<div>
<button ng-click="calculate_total()">Calculate Total</button>
<input value="{{total}}" />
</div>
</div>
<script src="angular.min.js"></script>
<script>
var myapp = angular.module('Intro', []);
myapp.controller('Products', ['$scope', function($scope) {
$scope.n_tables = 7;
$scope.n_hats = 50;
$scope.n_iphones = 2;
$scope.calculate_total = function() {
alert( Number($scope.n_tables) +
Number($scope.n_hats) +
Number($scope.n_iphones));
};
}]);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment