ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Custom Filter example in AngularJS<p>Hi rani,</p> <p>The custom filters is a filter that allow you to create your own custom filters logic with help of your own array expressions.</p> <p>The custom currency filter : {{ Salary | currency:"$"}}</p> <p>The custom date filter :- {{Date | date:"yyyy-MM-dd HH:mm:ss Z"}}</p> <p>The custom number filter :- {{ NumberExpressions | number : Fraction_Size}}</p> <p><strong><span style="text-decoration: underline;">Example</span></strong></p> <div class="demo_block"> <pre class="brush: html">&lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.8/angular.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; var app = angular.module(&#39;MyApp&#39;, []); app.controller(&#34;MyController&#34;, function ($scope) { $scope.Students = [ { Id: 1, Name: &#34;Ram&#34;, Salary: 15000 }, { Id: 2, Name: &#34;Rahim&#34;, Salary: 26500 }, { Id: 3, Name: &#34;Ajay&#34;, Salary: 16986 }, { Id: 4, Name: &#34;Bijay&#34;, Salary: 22000 }]; }); app.filter(&#39;CustomCurrencyFractional&#39;, [&#39;$filter&#39;, &#39;$locale&#39;, function (filter, locale) { var currency_Filters = filter(&#39;currency&#39;); var decimalFormat = locale.NUMBER_FORMATS; return function (amountVal, currencyType) { var currencyValue = currency_Filters(amountVal, currencyType); var result = currencyValue.indexOf(decimalFormat.DECIMAL_SEP); if (amountVal &gt;= 0) { return currencyValue.substring(0, result); } else { return currencyValue.substring(0, result); } }; } ]); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div ng-app=&#34;MyApp&#34; ng-controller=&#34;MyController&#34;&gt; &lt;table border=&#34;1&#34;&gt; &lt;tr&gt; &lt;th&gt;Id&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Salary&lt;/th&gt; &lt;th&gt;Salary Fraction&lt;/th&gt; &lt;/tr&gt; &lt;tr ng-repeat=&#34;student in Students&#34;&gt; &lt;td&gt;{{student.Id}}&lt;/td&gt; &lt;td&gt;{{student.Name}}&lt;/td&gt; &lt;td&gt;{{student.Salary | currency }}&lt;/td&gt; &lt;td&gt;{{student.Salary | CustomCurrencyFractional:&#34;&pound;&#34; }}&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</pre> </div> <p><a class="demo button orange btn btn-red">Demo</a></p>https://www.aspforums.net:443/Threads/317967/Custom-Filter-example-in-AngularJS/https://www.aspforums.net:443/Threads/317967/Custom-Filter-example-in-AngularJS/Wed, 08 May 2019 02:09:51 GMT