(function () { var app = angular.module("Sports", []); var MainController = function($scope, $http) { var onUser = function (response) { obj = JSON.parse(response); $scope.sport = angular.fromJson(obj); }; $http.get("/api/SportApi/Get").success(function (response) { obj = JSON.parse(response); $scope.sport = angular.fromJson(obj); }); }; app.controller("MainController", ["$scope", "$http", MainController]); }());
So this script does not work, getting an error, it cannot find the "main controller as a function", what is the problem?
EDIT: The cause of the error in this function:
function consoleLog(type) { var console = $window.console || {}, logFn = console[type] || console.log || noop, hasApply = false; // Note: reading logFn.apply throws an error in IE11 in IE8 document mode. // The reason behind this is that console.log has type "object" in IE8... try { hasApply = !!logFn.apply; } catch (e) {} if (hasApply) { return function() { var args = []; forEach(arguments, function(arg) { args.push(formatError(arg)); }); return logFn.apply(console, args); //throws exception }; }
source share