Search code examples
angularjsangular-controller

AngularError - app.controller(...) is not a function


I would like to understand why this code works but when it runs, I get a message: app.controller(...) is not a function and how can I fix it?

  <script>
    var app = angular.module('filtraPedido', []);
    app.controller('listdata',function($scope, $http){


        $scope.pedidos = [{'pedidoData':'15/01/2016 17:03:10','pedidoId':'603530313428-01','pedidoStatus':'Pagamento Pendente','pedidoValor':'3398','produtoId':'29','produtoNome':'Garrafa Personalizada (350 ml)','produtoPreco':'1400','produtoPagamento':'Boleto Bancário','produtoSeller':'Seller Name','hostname':'seller1','pedidoEstado':'RJ','pedidoCidade':'Rio de Janeiro','pedidoBairro':'Pechincha','utmCampaing': '','utmMedium': '','utmSource': ''}];

        $scope.sort = function(keyname){
            $scope.sortKey = keyname;   //set the sortKey to the param passed
            $scope.reverse = !$scope.reverse; //if true make it false and vice versa
        }

    })();

  </script>

https://jsfiddle.net/andremiani/kac912ep/


Solution

  • Here is the updated fiddle. https://jsfiddle.net/kac912ep/3/

    Just removed the () from line 94.