I have a simple controller which works absolutely fine.
var myApp = angular.module('myApp', []);
myApp.controller('ProductController', ['$scope', function ($scope) {
$scope.Message = "Hello World";
} ]);
However, if I want to put this inside a function, i.e.
(function () {
var myApp = angular.module('myApp', []);
myApp.controller('ProductController', ['$scope', function ($scope) {
$scope.Message = "Hello World";
} ]);
});
I get the following error Error: ng:areq Bad Argument Argument 'ProductController' is not a function, got undefined
Html is like this
<body ng-app="myApp">
<div ng-controller="ProductController">
{{Message}}
</div>
</body>