Skip to content

Instantly share code, notes, and snippets.

@nonZero
Created June 21, 2016 07:56
Show Gist options
  • Save nonZero/87fe9f90cfa5ba0e004d0b454fde7133 to your computer and use it in GitHub Desktop.
Save nonZero/87fe9f90cfa5ba0e004d0b454fde7133 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en" ng-app>
<head>
<meta charset="UTF-8">
<title>Super Angular!!!</title>
<style>
.ng-cloak {
display: none;
}
</style>
</head>
<body>
<p>
Angular is an MVC framework.
</p>
<div ng-if="false">
LOADING....
</div>
<div id="foo" class="ng-cloak">
<!-- do not actually use ng-init!!! -->
<ul ng-init="factor=0.9; products = [
{name:'milk', price:10},
{name:'cheese', price:20},
{name:'apple', price:12}
]">
<input type="number" step="0.1" ng-model="factor">
<div>
<input type="text" ng-model="name">
<input type="number" ng-model="price">
<button ng-click="products.push({name:name, price:price})">Add</button>
</div>
<li ng-repeat="item in products">
[{{ $index }}]
{{item.name}}: ${{factor * item.price |number:2}}
<button ng-click="products.splice($index, 1)">Delete</button>
</li>
</ul>
</div>
<script src="angular.js"></script>
<script src="app.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment