Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Should i move my filter function to an actual angular.filter for the sake of standards compliance?</p> </blockquote> <p>Right, the better way to use filters as utility (like singletons as service, provider, factory).</p> <p>The filter doesn't use <code>$scope</code> it creates output based on input, therefore you can write your filter like:</p> <pre><code>app.filter('myfilter', function() { return function( items, types) { var filtered = []; angular.forEach(items, function(item) { // &lt;some conditions&gt; filtered.push(item); // dummy usage, returns the same object } }); return filtered; }; }); </code></pre> <p>Took from <kbd><a href="http://plnkr.co/edit/b0LMJzUiJy0NO9Hk0oWt?p=preview" rel="nofollow">Fiddle</a></kbd> Demo</p> <p><strong>As reference</strong></p> <p>If you use codeigniter framework with <a href="https://github.com/angular/angular-seed" rel="nofollow">angular seed</a>, you can see that they use seprate file named:</p> <pre><code>filters.js --&gt; custom angular filters </code></pre> <p>And project structure looks like:</p> <pre><code>app/ --&gt; all of the files to be used in production css/ --&gt; css files app.css --&gt; default stylesheet img/ --&gt; image files index.html --&gt; app layout file (the main html template file of the app) index-async.html --&gt; just like index.html, but loads js files asynchronously js/ --&gt; javascript files app.js --&gt; application controllers.js --&gt; application controllers directives.js --&gt; application directives filters.js --&gt; custom angular filters services.js --&gt; custom angular services lib/ --&gt; angular and 3rd party javascript libraries angular/ angular.js --&gt; the latest angular js angular.min.js --&gt; the latest minified angular js angular-*.js --&gt; angular add-on modules version.txt --&gt; version number partials/ --&gt; angular view partials (partial html templates) partial1.html partial2.html </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload