Client side filtering.
If you are not looking for anything crazy that can be achieved in a super easy way for a global search. I did not even know if this would work, so I just did a quick check, and it is. Obviously, this could be solved in a much more detailed and controlled way, using services and implementing them where they are needed. But since I donβt know what you are looking for, I will provide this solution, if you like it, agree to this. If you do not, then I can probably help you with the injection solution in the service
A quick fix is ββto have a widescreen application controller with $ rootScope ng-model. Let's call it global.search.
$rootScope.global = { search: '' };
For advanced in-app search.
<form> <label>Search</label> <input ng-model="global.search" type="text" class="form-control" /> </form>
In separate elementary parts, you just need to filter data based on global.search ng-model. Two examples
<p ng-repeat="post in posts | filter: global.search">{{ post.name }}</p>
The second template with a different area
<p ng-repeat="video in videos | filter: global.search">{{ video.name }}</p>
Notice how they implement | filter: global.search. Whenever global.search changes, any filters in the current view will be changed. Thus, messages will be filtered by viewing messages and videos in the form of video viewing. When using the same global model global.search ng.
I tested this, it works. If you need to explain the hierarchy of the installation and the child controller in more detail, let me know. Here is a quick overview of the complete template.
<html> <body ng-controller="AppController"> <form> <label>Search</label> <input ng-model="global.search" type="text" class="form-control" /> </form> <div ui-view="posts"> <div ng-controller="PostController"> <p ng-repeat="post in posts | filter: global.search">{{ post.name }}</p> </div> </div> <div ui-view="videos"> <div ng-controller="VideoController"> <p ng-repeat="video in videos | filter: global.search">{{ video.name }}</p> </div> </div> </body> </html>