How to use the custom code in my case



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:

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 = {
      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?