Angular 1.3 has deprecated the use of global controller declarations on the global scope. This issue manifests as an error stating "Argument 'ContactController' is not a function, got undefined," preventing controllers from being defined globally without explicit registration.
To fix this, controllers should be registered using the module.controller syntax. For example:
angular.module('app', []).controller('ContactController', ['$scope', function ContactController($scope) { // Controller logic }]);
Alternatively, you can inject the controller as a function:
function ContactController($scope) { // Controller logic } ContactController.$inject = ['$scope']; angular.module('app', []).controller('ContactController', ContactController);
If you prefer to use global declarations, you can enable them by setting allowGlobals in the $controllerProvider.
angular.module('app') .config(['$controllerProvider', function($controllerProvider) { $controllerProvider.allowGlobals(); }]);
The above is the detailed content of How to Fix 'Argument 'ContactController' is not a function' Errors in Angular 1.3 ?. For more information, please follow other related articles on the PHP Chinese website!