Reputation: 1574
I make a auto suggest using filter .It show when user type on input field .But when user select any row of table I need to hide that table .In my my case I am not able to hide the table can you please tell me how to hide the table after select of row here is my fiddle
http://jsfiddle.net/66z4dxsy/2/ .In other word.When I run the program my table is hide .when I type on input field it show but when I select it again hide how I will achieve this.Please disable web security of browser .because it show cross domain error .
var app=angular.module("myapp",[]);
function cnt($scope,$http){
$http.get("http://192.168.11.56/sstest")
.success(function (data) {
//alert(data);
$scope.d=data;
}).error(function(data){
alert("error")
});
$scope.getselectedRow=function(obj){
alert(obj.stationName) ;
$scope.searchText.stationCode= obj.stationCode;
}
}
Thanks
Thanks
Upvotes: 0
Views: 158
Reputation: 952
Because the visibility of your table is bound to:
<table ng-show="searchText.stationCode && searchText.stationCode.length != 0">
All you have to do is to set searchText.stationCode = null
in your code. If you are in some asynchronous context (callback from an ajax) you might need to force update
$scope.searchText.stationCode = null;
$scope.$apply()
Upvotes: 0
Reputation: 5826
I don't know what you want to achieve by doing this but what you want that can be done by adding one more condition as below.
<input type="text" ng-model="searchText.stationCode" ng-focus="selected=true">
See updated fiddle here Fiddle Link
Upvotes: 1