I have one search box on one page, i.e. header.html , and the list on which I want to implement the search function is on another page, i.e. content.html , So, how can I use the angularjs search function in this case . Below is the html code.
header.html
<div class="input-group col-md-12 search-inner-page "> <input type="text" class="form-control" placeholder="Search" name="q"> </div>
content.html
<div class="surveyList" ng-repeat="survey in allSurveys"> <span class="checkbox" ></span> <div class="toogleSurvey row" ng-mouseover="hoverIn()" ng-mouseleave="hoverOut()"> <div class="col-xs-5 col-sm-2 col-md-2">{{survey.Name}}</div> <div class="col-xs-5 col-sm-1 col-md-1">{{survey.Type}}</div> <div class="col-sm-3 col-md-3 hidden-xs">{{survey.SurveyReference}}</div> <div class="col-sm-3 col-md-3 hidden-xs">{{survey.CreatedDate}}</div> <div class="col-sm-2 col-md-2 hidden-xs SurveyLastChild">{{survey.Status}}</div> <div class="hidden-xs surveyListTool" ng-show="hoverEdit"> <a class="editSurvey" title="edit"></a> <a class="deleteSurvey" title="delete"></a> <a class="exportSurvey" title="export survey"></a> <a class="menuSurvey" title="menu"></a> </div> </div>
contentCtrl.js
angular.module("adminsuite").controller("surveyController",['getAllSurveyService','AuthenticationService', '$scope','$rootScope', '$state', function(getAllSurveyService,AuthenticationService, $scope,$rootScope,$state){ getAllSurveyService.surveyList().then( function( data ) { $scope.allSurveys = data; console.log($scope.allSurveys); if($scope.allSurveys.ErrorMessage){ AuthenticationService.ClearCredentials(); $state.go('login'); } } ); }]);
headerController.js
angular.module("adminsuite").controller("headerController",['AuthenticationService','$rootScope','$cookieStore','$scope',function(AuthenticationService,$cookieStore,$scope,$rootScope){ $scope.header = "Header"; $scope.searchInSurvey = $scope.surveySearch; $scope.logout = function(){ //$scope.dataLoading = true; AuthenticationService.ClearCredentials(); console.log($cookieStore.get('globals')); //$state.go('login'); }; }]);
When entering text in the header.html search field , as indicated above, it should search for content on the content.html page.