AngularError - app.controller(...) 不是函数
AngularError - app.controller(...) is not a function
我想了解为什么这段代码可以运行,但是当它运行时,我收到一条消息:app.controller(...) is not a function 以及如何我可以修复它吗?
<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>
您正在尝试使用
立即执行您的 app.controller 注册功能
app.controller('listdata',function($scope, $http){
...
})();
这是不正确的,因为 app.controller 不是可以调用的函数。只需删除结束参数。
app.controller('listdata',function($scope, $http){
...
});
这是更新后的 fiddle。 https://jsfiddle.net/kac912ep/3/
刚刚从第 94 行删除了 ()
。
我想了解为什么这段代码可以运行,但是当它运行时,我收到一条消息:app.controller(...) is not a function 以及如何我可以修复它吗?
<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>
您正在尝试使用
立即执行您的 app.controller 注册功能app.controller('listdata',function($scope, $http){
...
})();
这是不正确的,因为 app.controller 不是可以调用的函数。只需删除结束参数。
app.controller('listdata',function($scope, $http){
...
});
这是更新后的 fiddle。 https://jsfiddle.net/kac912ep/3/
刚刚从第 94 行删除了 ()
。