Created
October 25, 2015 18:14
-
-
Save DanWahlin/e3306ce06cd08811f4bc to your computer and use it in GitHub Desktop.
Simple Angular App with Controller
This file contains 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
<html ng-app="app"> | |
<body> | |
<div ng-controller="CustomersController"> | |
Name: <input type="text" ng-model="searchText" /> {{ searchText }} | |
<br /> | |
<ul> | |
<li ng-repeat="person in people | filter:searchText | orderBy:'name' track by person.id"> | |
{{ ::person.name }} - {{ ::person.city }} | |
</li> | |
</ul> | |
</div> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js"></script> | |
<script> | |
angular | |
.module('app', []) | |
.controller('CustomersController', CustomersController); | |
function CustomersController($scope) { | |
$scope.people=[ | |
{id: 1, name: 'Ward', city: 'San Francisco'}, | |
{id: 2, name: 'Shirley', city: 'Phoenix'}, | |
{id: 3, name: 'John', city: 'Orlando'}, | |
{id: 4, name: 'Buttercup', city: 'La La Land'} | |
]; | |
$scope.searchText = ''; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment