Skip to content

Instantly share code, notes, and snippets.

@tirams
Last active August 29, 2015 14:17
Show Gist options
  • Save tirams/08dc893114dd4872d8eb to your computer and use it in GitHub Desktop.
Save tirams/08dc893114dd4872d8eb to your computer and use it in GitHub Desktop.
Angular Demo// source http://jsbin.com/noquci
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.js"></script>
<meta charset=utf-8 />
<title>Angular Demo</title></head>
<body ng-app>
<h1>Angular.JS Simple Markup Demo</h1>
<div id='cons'>
</div>
<h2>New Customer</h2>
<!-- angulare will create a newCustomer object be we need to clear after use -->
<form ng-submit="customers.push(newCustomer); newCustomer={}">
<label>Customer Name:
<input ng-model="newCustomer.name" />
</label>
<button type="submit">Add Customer</button>
</form>
<h2><span ng-hide="customers.length<=0" >{{customers.length}}</span> Current Customers</h2>
<!-- hide the no customers message is there are > 0 items -->
<p ng-hide="customers.length>0">No customers yet</p>
<ol ng-hide="customers.length<=0" ng-init="customers=[]">
<li ng-repeat="customer in customers">
{{customer.name}}
(<a href='javascript:void(0)'
ng-click="customers.splice($index,1);">x</a>)
</li>
<p>customers</p>
</ol>
<script>
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment