How to use the custom code in my case


#1

Hi,

In creator, usually i add the custom-code for the controller in each page inside the function,

for example:
function ($scope, $stateParams) { HERE }

now the code i like to add this time is go out from the function of the page
its in here:

https://codepen.io/amwill/pen/qbXGao?q=Angular%20filter&order=popularity&depth=everything&show_forks=false

for example:

var app = angular.module('myApp', []);

app.controller('FilterCtrl', function() {
  var vm = this;
  vm.filterValue = '';
  vm.filterData = [
    { name: 'Aang', bender: 'yes', nation: 'Air', show: 'ATLA' },
    { name: 'Appa', bender: 'yes', nation: 'Air', show: 'ATLA' },
    { name: 'Zuko', bender: 'yes', nation: 'Fire', show: 'ATLA' }
  ];
  vm.filterItems = function filterItems(val) {
    vm.filterValue = val;
  }
}).filter('uniqueVal', function() {
  return function(data, val) {
    var propsData = data.map(function(item) {
      return item[val];
    });
    var uniqueData = _.uniq(propsData);
    return uniqueData;
  }
});

can someone understand and try to help me how i should add this code to the creator?