I'm using a $http get request in my angular application to access data to bind to my view in a loop using ng-repeat and a filter based on a users input value for a simple search. I'm able to access the data and filter and bind the results to my view but the search only happens when the second character the user types is on keyup, not the first character. I want my search to happen on the first keyup.
MY CONTROLLER:
angular.module("app.findfriendsApp").controller("FindfriendsCtrl", [
'$scope', '$http',
($scope, $http)->
# Get Request.
$http.get('find_friends.json').success((data, status, headers, config)->
$scope.friends = data;
).error((data, status, headers, config)->
log error
)
])
MY VIEW:
main ng-app="app.findfriendsApp"
.container ng-controller="FindfriendsCtrl"
.row
.col-xs-12
input[type="text"
ng-model="search"
placeholder="Search by Name"]
.col-xs-12
ul
li[ng-repeat="friend in filteredData = (friends | filter:search)"
ng-hide="filteredData.length==friends.length"]
|{{friend.username}}