(function() {
    'use strict';

    angular
        .module('app')
        .controller('searchbarController', searchbarController)
    
    function searchbarController($scope, show) {
      $scope.itemArray = [];
      //event handler function for every change in input
      $scope.searchImdb = function(title){
        if(title.length > 1){
          show.search(title).then(function(data){
            if(data !== undefined){
              $scope.itemArray = data;
            }
          })
        } else {
          $scope.itemArray = [];
        }
      }
      //save selected show to user
      $scope.selection= function(selected){
        //selected show
        show.save(selected).then(function(data){
          console.log(data);
        })

      }      
    }


  })();
(function() {
    'use strict';

    angular
        .module('app')
        .controller('searchbarController', searchbarController)
    
    function searchbarController($scope, show) {
      $scope.itemArray = [];
      //event handler function for every change in input
      $scope.searchImdb = function(title){
        if(title.length > 1){
          show.search(title).then(function(data){
            if(data !== undefined){
              $scope.itemArray = data;
            }
          })
        } else {
          $scope.itemArray = [];
        }
      }
      //save selected show to user
      $scope.selection= function(selected){
        show.save(selected).then(function(data){
          console.log(data);
        })

      }      
    }


  })();
comment update