For this to work there are some support libraries and frameworks that you need to include. I suspect you might have already included the same unless you are starting afresh. But here is for the sake of being specific. Please include searchbarJs and searchbar.css for the search bar to work as expected.
<script data-require="jquery@*" data-semver="2.1.4" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script data-require="angular.js@1.4.7" data-semver="1.4.7" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js"></script>
<link data-require="bootstrap@*" data-semver="3.3.5" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<!--this is what is needed to include when you want to access the search bar-->
<script src="http://vpunplepun2-01:8082/searchbar/searchbar.js"></script>
<link rel="stylesheet" href="http://vpunplepun2-01:8082/searchbar/searchbar.css">
Please see I'm currently making this custom control avilable only over intranet in my domain, but once this is running without any bugs I would want to move this to public cloud.
The code below shows your angular needs support. The searchbar runs in the container app "app.searchbar"
var myApp = angular.module("myApp",["app.searchbar"])
Search bar displays suggestions for a certain field. The collections of search can be complex objects but the search bar can be customized in the manifestation for displaying a certain field in the suggestions list.
<!--please make a note the field value is a string -->
<search-bar disp-field="'alias'"></search-bar>
and that would get the object.alias for the display list in the suggestions
Just tune into the attribute : 'sel-item' and you are done!
<!--please make a note the field value is a string -->
<search-bar sel-item="selEmp"></search-bar>
$scope.selEmp = null;
$scope.$watch('selEmp', function(newValue, oldValue){
console.log("we have selected the new employee from the suggestion:" + newValue.alias);
});
I agree, that this control though can be a re-use candidate, the service that does the search cannot be. Services are injectables and dependency injection pattern is waiting to be employed here. From your main controller just inject the service call in the attribute 'service-call'. Directive expects this service call to use promises and even has a waiting animation in the suggestions flyout!
Here is the manifestation
<search-bar service-call='empServiceCall(phrase)'></search-bar>
and from the mainController (or any other controller that encircles the directive here is what it would look like
$scope.empServiceCall = function(phrase){
return empService.getLikeEmp(phrase); //returns the promise from function call below
}
<table class="result-table"></table>
notice the class result-table on the table. just slap this so that the search suggestions overlay the table. This class is a part of searchbar.js