-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[ | ||
{ | ||
"id": 1, | ||
"name": "Peyton Manning", | ||
"phone": "(303) 567-8910", | ||
"address": { | ||
"street": "1234 Main Street", | ||
"city": "Greenwood Village", | ||
"state": "CO", | ||
"zip": "80111" | ||
} | ||
}, | ||
{ | ||
"id": 2, | ||
"name": "Demaryius Thomas", | ||
"phone": "(720) 213-9876", | ||
"address": { | ||
"street": "5555 Marion Street", | ||
"city": "Denver", | ||
"state": "CO", | ||
"zip": "80202" | ||
} | ||
}, | ||
{ | ||
"id": 3, | ||
"name": "Von Miller", | ||
"phone": "(917) 323-2333", | ||
"address": { | ||
"street": "14 Mountain Way", | ||
"city": "Vail", | ||
"state": "CO", | ||
"zip": "81657" | ||
} | ||
} | ||
] |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
angular | ||
.module('myApp') | ||
.controller('SearchController', SearchController); | ||
|
||
SearchController.$inject = ['SearchService']; | ||
|
||
function SearchController(SearchService) { | ||
var vm = this; | ||
|
||
vm.search = function () { | ||
SearchService.search(vm.term, function (response) { | ||
vm.searchResults = response; | ||
}); | ||
}; | ||
} | ||
})(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<form ng-submit="vm.search()"> | ||
<input type="search" name="search" ng-model="vm.term"> | ||
<button>Search</button> | ||
</form> | ||
|
||
<table ng-show="vm.searchResults.length"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Phone</th> | ||
<th>Address</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr ng-repeat="person in vm.searchResults"> | ||
<td>{{person.name}}</td> | ||
<td>{{person.phone}}</td> | ||
<td>{{person.address.street}}<br/> | ||
{{person.address.city}}, {{person.address.state}} {{person.address.zip}} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
angular | ||
.module('myApp') | ||
.factory('SearchService', SearchService); | ||
|
||
SearchService.$inject = ['$resource']; | ||
|
||
function SearchService($resource) { | ||
var Search = $resource('/api/search/people.json'); | ||
|
||
Search.search = function (term, callback) { | ||
Search.query(function (response) { | ||
var results = response.filter(function (item) { | ||
return JSON.stringify(item).toLowerCase().includes(term.toLowerCase()); | ||
}); | ||
return callback(results); | ||
}); | ||
}; | ||
|
||
return Search; | ||
} | ||
})(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
angular.module('myApp') | ||
.config(stateConfig); | ||
|
||
stateConfig.$inject = ['$stateProvider']; | ||
|
||
function stateConfig($stateProvider) { | ||
$stateProvider | ||
.state('search', { | ||
url: '/search', | ||
templateUrl: 'search/search.html', | ||
controller: 'SearchController', | ||
controllerAs: 'vm' | ||
}); | ||
} | ||
})(); |
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