Created
November 25, 2013 16:38
-
-
Save ynonp/7644250 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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