title: AngularJS Filter: Hexadecimal
body: <p>I'm trying to apply a filter that takes a decimal input and outputs hexadecimal through an AngularJS filter. I'm unsure as to why the filter isn't applied. I've checked the conversion with sample data in the console, e.g. 10 --> a</p>
  
  <p>Any advice? Thanks!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var app = angular.module("myApp", []);
  
  app.filter('hex', function () {
    
    return function(input) {
      return (input).toString(16);
    };
  });
  
  
  app.controller('hexCtrl', ['$scope', 'hexFilter', function($scope, hexFilter) {
      // Initialize initial values.
      $scope.decimal = 0;
  
  }]);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div ng-app="myApp" ng-controller="hexCtrl"&gt;
    &lt;p&gt;This input takes decimal: &lt;input type="text" ng-model="decimal"&gt;&lt;/p&gt;
    &lt;p&gt;Returns a hexadecimal: {{ decimal | hex }}&lt;/p&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>