diff --git a/app/partials/ContactView/ContactView.controller.js b/app/partials/ContactView/ContactView.controller.js index 6cc630f..ff913fd 100644 --- a/app/partials/ContactView/ContactView.controller.js +++ b/app/partials/ContactView/ContactView.controller.js @@ -13,6 +13,30 @@ $scope.contactList = result; }) + $scope.search = ""; + $scope.minlength = 2; + + + $scope.searchString= function(value){ + ContactViewService.getSearchResults(value).then(function(result) { + $scope.contactList = result; + console.log("result", result); + for (var i = 0; i < $scope.contactList.length; i++) { + if ($scope.contactList[i].owner != null) { + if ($scope.contactList[i].owner.companyName != null || $scope.contactList[i].owner.companyName != undefined) { + $scope.contactList[i].owner = $scope.contactList[i].owner.companyName; + } + } + } + $scope.displayContactList = new NgTableParams({ + page: 1, + count: 10, + }, { + data: $scope.contactList + }); + }) + } + $scope.reset = function(){ $("input").val(""); } @@ -55,10 +79,10 @@ } - /*ContactViewService.getCompanies().then(function(result) { + ContactViewService.getCompanies().then(function(result) { $scope.companies = result; - })*/ + }) $scope.contactData = {}; $scope.contactData.contactList = []; diff --git a/app/partials/ContactView/ContactView.html b/app/partials/ContactView/ContactView.html index 8ec299e..0a40c95 100644 --- a/app/partials/ContactView/ContactView.html +++ b/app/partials/ContactView/ContactView.html @@ -26,7 +26,7 @@ -
  • +
  • diff --git a/app/partials/ContactView/ContactView.service.js b/app/partials/ContactView/ContactView.service.js index 3d4db00..be99a10 100644 --- a/app/partials/ContactView/ContactView.service.js +++ b/app/partials/ContactView/ContactView.service.js @@ -21,6 +21,22 @@ }) return deferred.promise; } + + this.getSearchResults = function(param) { + + var deferred = $q.defer(); + $http({ + method : 'GET', + url : BASE_URL.url +'/company/contact/search?param='+param, + headers : {'Content-Type': 'application/json'}, + }) + .then(function (result){ + deferred.resolve(result.data); + },function (result){ + deferred.resolve(result.data); + }) + return deferred.promise; + } this.getCompanies = function() {