Skip to content

Instantly share code, notes, and snippets.

Created September 4, 2014 14:18
Show Gist options
  • Save anonymous/a194f780ba2f362ebb04 to your computer and use it in GitHub Desktop.
Save anonymous/a194f780ba2f362ebb04 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body ng-app="demoApp">
<div ng-controller="myCtrl">
<p>Name:</p>
<input type="text" ng-model="newPerson.name">
<p>City:</p>
<input type="text" ng-model="newPerson.city">
<button type="submit" ng-click="addPerson()">Submit</button>
<ul>
<li ng-repeat="person in persons">
{{person.name}} - {{person.city}}
</ul>
</div>
<script id="jsbin-javascript">
var demoApp = angular.module('demoApp',[]);
demoApp.controller('myCtrl', function ($scope){
$scope.persons = [
{name: 'Edwin Luisenbarn',city:'Cebu'},
{name: 'JM Rivera',city:'Mandaue'}
];
$scope.addPerson = function() {
$scope.persons.push({
name:$scope.newPerson.name,
city:$scope.newPerson.city
})
};
});
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"><\/script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body ng-app="demoApp">
<div ng-controller="myCtrl">
<p>Name:</p>
<input type="text" ng-model="newPerson.name">
<p>City:</p>
<input type="text" ng-model="newPerson.city">
<button type="submit" ng-click="addPerson()">Submit</button>
<ul>
<li ng-repeat="person in persons">
{{person.name}} - {{person.city}}
</ul>
</div>
</body>
</html></script>
<script id="jsbin-source-javascript" type="text/javascript">var demoApp = angular.module('demoApp',[]);
demoApp.controller('myCtrl', function ($scope){
$scope.persons = [
{name: 'Edwin Luisenbarn',city:'Cebu'},
{name: 'JM Rivera',city:'Mandaue'}
];
$scope.addPerson = function() {
$scope.persons.push({
name:$scope.newPerson.name,
city:$scope.newPerson.city
})
};
});
</script></body>
</html>
var demoApp = angular.module('demoApp',[]);
demoApp.controller('myCtrl', function ($scope){
$scope.persons = [
{name: 'Edwin Luisenbarn',city:'Cebu'},
{name: 'JM Rivera',city:'Mandaue'}
];
$scope.addPerson = function() {
$scope.persons.push({
name:$scope.newPerson.name,
city:$scope.newPerson.city
})
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment