{"id":236,"date":"2017-03-23T11:02:32","date_gmt":"2017-03-23T11:02:32","guid":{"rendered":"http:\/\/codeinsightacademy.com\/blog\/?p=236"},"modified":"2017-05-11T15:18:10","modified_gmt":"2017-05-11T15:18:10","slug":"filters","status":"publish","type":"post","link":"https:\/\/codeinsightacademy.com\/blog\/angular-js\/filters\/","title":{"rendered":"Filters"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;DOCTYPE html&gt;\r\n    &lt;html&gt;\r\n        &lt;head&gt;\r\n            &lt;meta CHARSET=\"UTF-8\"&gt;\r\n            &lt;script src=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/angularjs\/1.4.8\/angular.min.js\"&gt;&lt;\/script&gt;\r\n        &lt;\/head&gt;\r\n        &lt;body ng-app=\"myApp\" ng-controller=\"myCtrl\"&gt;\r\n            &lt;h2&gt;Filters (uppercase, lowercase, currency, filter, Custom filter)&lt;\/h2&gt;\r\n            &lt;fieldset&gt;\r\n                &lt;legend&gt;\r\n                    Uppercase\r\n                &lt;\/legend&gt;\r\n                &lt;div ng-init='name = {\"first_name\":\"Shailesh\"}'&gt;\r\n                    {{name.first_name| uppercase}}\r\n                &lt;\/div&gt;\r\n            &lt;\/fieldset&gt;\r\n            &lt;fieldset&gt;\r\n                &lt;legend&gt;\r\n                    Lowercase\r\n                &lt;\/legend&gt;\r\n                &lt;div ng-init='month = {\"first\":\"january\"}'&gt;\r\n                    {{month.first| lowercase}}\r\n                &lt;\/div&gt;\r\n            &lt;\/fieldset&gt;\r\n            &lt;fieldset&gt;\r\n                &lt;legend&gt;\r\n                    Currency\r\n                &lt;\/legend&gt;\r\n                &lt;div ng-init='currency = {\"inr\": 20000, \"usd\":30000, \"euro\": 25000}'&gt;\r\n                    &lt;!-- {{ currency_expression | currency : symbol : fractionSize}} --&gt;\r\n                    {{currency.inr| currency : ' &amp;#8377;' : 3}} &lt;br\/&gt;\r\n                    {{currency.usd| currency}} &lt;br\/&gt;\r\n                    {{currency.euro| currency : '&amp;euro;'}}\r\n                &lt;\/div&gt;\r\n            &lt;\/fieldset&gt;\r\n            &lt;fieldset&gt;\r\n                &lt;legend&gt;\r\n                    Single Filter\r\n                &lt;\/legend&gt;\r\n                &lt;div ng-init='city = [\"Mumbai\", \"Pune\", \"Nagpur\"]'&gt;\r\n                    &lt;table border=\"1\"&gt;\r\n                        &lt;ul&gt;\r\n                            &lt;li ng-repeat=\"x in city\"&gt;\r\n                                {{x}}\r\n                            &lt;\/li&gt;\r\n                        &lt;\/ul&gt;\r\n                    &lt;\/table&gt;\r\n                &lt;\/div&gt;\r\n            &lt;\/fieldset&gt;\r\n            &lt;fieldset&gt;\r\n                &lt;legend&gt;\r\n                    Multiple Filter\r\n                &lt;\/legend&gt;\r\n                &lt;div&gt;\r\n                    Search by any &lt;input type=\"text\" name=\"\" ng-model=\"search.$\"\/&gt; &lt;br\/&gt;\r\n                    Search by Name &lt;input type=\"text\" name=\"\" ng-model=\"search.name\"\/&gt; &lt;br\/&gt;\r\n                    Search Country &lt;input type=\"text\" name=\"\" ng-model=\"search.country\"\/&gt; &lt;br\/&gt;\r\n                    &lt;table border=\"1\"&gt;\r\n                        &lt;tr ng-repeat=\"x in emp_records| filter:search\"&gt;\r\n                            &lt;td&gt;{{x.name}}&lt;\/td&gt;\r\n                            &lt;td&gt;{{x.country}}&lt;\/td&gt;\r\n                            &lt;td&gt;{{x.age}}&lt;\/td&gt;\r\n                        &lt;\/tr&gt;\r\n                    &lt;\/table&gt;\r\n                &lt;\/div&gt;\r\n            &lt;\/fieldset&gt;\r\n            &lt;fieldset&gt;\r\n                &lt;legend&gt;\r\n                    Multiple Filter Skip Few\r\n                &lt;\/legend&gt;\r\n                &lt;div&gt;\r\n                    Search by Name or Country Only &lt;input type=\"text\" name=\"\" ng-model=\"query\"\/&gt; &lt;br\/&gt;\r\n                    &lt;table border=\"1\"&gt;\r\n                        &lt;tr ng-repeat=\"x in emp_records| filter:search2\"&gt;\r\n                            &lt;td&gt;{{x.name}}&lt;\/td&gt;\r\n                            &lt;td&gt;{{x.country}}&lt;\/td&gt;\r\n                            &lt;td&gt;{{x.age}}&lt;\/td&gt;\r\n                        &lt;\/tr&gt;\r\n                    &lt;\/table&gt;\r\n                &lt;\/div&gt;\r\n            &lt;\/fieldset&gt;\r\n        &lt;\/body&gt;\r\n        &lt;script&gt;\r\n            var app = angular.module(\"myApp\", []);\r\n            app.controller(\"myCtrl\", function ($scope) {\r\n                $scope.emp_records = [\r\n                    {name: 'Jani', country: 'Norway', 'age': 20},\r\n                    {name: 'Carl', country: 'Sweden', 'age': 21},\r\n                    {name: 'Margareth', country: 'England', 'age': 22},\r\n                    {name: 'Hege', country: 'Norway', 'age': 23},\r\n                    {name: 'Joe', country: 'Denmark', 'age': 24},\r\n                    {name: 'Gustav', country: 'Sweden', 'age': 25},\r\n                    {name: 'Birgit', country: 'Denmark', 'age': 26},\r\n                    {name: 'Mary', country: 'England', 'age': 27},\r\n                    {name: 'Kai', country: 'Norway', 'age': 28}\r\n                ];\r\n\r\n                $scope.search2 = function (row) {\r\n                    return (angular.lowercase(row.name).indexOf(angular.lowercase($scope.query) || '') !== -1 ||\r\n                            angular.lowercase(row.country).indexOf(angular.lowercase($scope.query) || '') !== -1);\r\n                };\r\n            });\r\n\r\n        &lt;\/script&gt;\r\n    &lt;\/html&gt;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta CHARSET=&#8221;UTF-8&#8243;&gt; &lt;script src=&#8221;http:\/\/ajax.googleapis.com\/ajax\/libs\/angularjs\/1.4.8\/angular.min.js&#8221;&gt;&lt;\/script&gt; &lt;\/head&gt; &lt;body ng-app=&#8221;myApp&#8221; ng-controller=&#8221;myCtrl&#8221;&gt; &lt;h2&gt;Filters (uppercase, lowercase, currency, filter, Custom filter)&lt;\/h2&gt; &lt;fieldset&gt; &lt;legend&gt; Uppercase &lt;\/legend&gt; &lt;div ng-init=&#8217;name = {&#8220;first_name&#8221;:&#8221;Shailesh&#8221;}&#8217;&gt; {{name.first_name| uppercase}} &lt;\/div&gt; &lt;\/fieldset&gt; &lt;fieldset&gt; &lt;legend&gt; Lowercase &lt;\/legend&gt; &lt;div ng-init=&#8217;month = {&#8220;first&#8221;:&#8221;january&#8221;}&#8217;&gt; {{month.first| lowercase}} &lt;\/div&gt; &lt;\/fieldset&gt; &lt;fieldset&gt; &lt;legend&gt; Currency &lt;\/legend&gt; &lt;div ng-init=&#8217;currency = {&#8220;inr&#8221;: 20000, &#8220;usd&#8221;:30000, &#8220;euro&#8221;: 25000}&#8217;&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/236"}],"collection":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/comments?post=236"}],"version-history":[{"count":3,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/236\/revisions"}],"predecessor-version":[{"id":247,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/posts\/236\/revisions\/247"}],"wp:attachment":[{"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/media?parent=236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/categories?post=236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeinsightacademy.com\/blog\/wp-json\/wp\/v2\/tags?post=236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}