Skip to main content

Posts

Showing posts with the label filter nested properties in angularjs object

AngularJs Filter Example Fiddles [How To Search]

In this post, I am going to share the demo example for “ Filter Array Object ” Example using “ TextBox ” in Angular 1.5. In the below example, I have a “ Products Object ” and render on the “ Table Grid ” and after that filter product grid using the Search textbox . Stayed Informed – Live demo Example [fiddles and plunker] The Example as, JavaScript Code, <script> angular.element( document ).ready( function () { var app = angular.module( 'myApp' , []); app.controller( 'myCtrl' , [ '$scope' , 'store' , function ($scope, store) { $scope.search = '' ; $scope.products = []; $scope.products = store.getProducts(); $scope.filterProductsByCategory = function (category) { $scope.search = category; }; }]); // fake service, substitute with your server call ($http) app.factory( 'store' , function () { var products = [{ ...

filter nested properties in angularjs object

We can write the nested properties look like below code. Go to live demo link http://embed.plnkr.co/CN8fO7/preview ? 1 <li ng-repeat= "country in countries | filter: { locations: [{ cityId: search.locations.cityId }] }" > <li ng-repeat="shop in shops | filter: { locations: [{ cityId: search.locations.cityId }] }"> The AngularJs Reference file is ? 1 <script src= "//ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js" ></script> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script> The code-sample for HTML page ? 1 2 3 4 5 6 7 8 9 <body ng-app= "myApp" >    <div ng-controller= "ngController" >      <input type= "text" ng-model= "Selected_CityId" />      <div ng-repeat= "country in countries | filter : search" >        Count...