当前位置: 动力学知识库 > 问答 > 编程问答 >

angularjs - How to do autocomplete in ionic & angulajs

问题描述:

I use Ubuntu(64-bit) and chrome for my logs.

I am new to ionic, I have started creating application on it. For last few days, I have been searching for autocomplete in ionic. I found a codepan but it's not that simple one.

I am getting error like

TypeError: iElement.autocomplete is not a function

Here is my code what i have done till now

In my html

 <label class="item item-input">

<input type="text" placeholder="Flat Number" ng-model="flatNo" name="srch" id="srch" ng-repeat="flatNumber">

</label>

<br>

<button class ="button button-calm" ng-click="checkResident(flatNo)">check</button>>

My app.js looks like this

app.directive('autoComplete', function($timeout) {

return function($scope, iElement, iAttrs) {

iElement.autocomplete({

source: $scope[iAttrs.uiItems],

select: function() {

$timeout(function() {

iElement.trigger('input');

}, 0);

}

});

}

});

app.controller('auto',function($scope,$http){

$scope.flatNumber=[];

$http.get("http://aflaree.com/apmsservice/securityService.svc/flatnodd")

.success(function(response){

console.log(response);

$scope.objectResponse = response.FLats;

$scope.objectResponse.forEach(function(item) {

$scope.flatNumber.push(item.Flat_No);

})

})

.error(function(response){

console.log(response);

});

$scope.checkResident = function(flatNo){

console.log(flatNO);

};

});

In my $scope.flatNumbers i have my data which i have pushed to it and on user enters the data in text field in should show the relevant information for the entered data.

Here on entering the Flatno and clicking the button it should display the username and mobile number that can be seen in alert box.

分享给朋友:
您可能感兴趣的文章:
随机阅读: