I recently took over a legacy VB.Net application and noticed that both the ng-app and ng-controller directives are present on the HTML element in the root master page:
<html runat="server" id="html" ng-controller="MasterController">
The ng-app
attribute is set in the code-behind for the page. When I run the page and inspect the source, I can see it there. The app is scoped to the module ng-app="myModule"
The controller is defined within a function passed to add_load
in the masterpage, situated not quite at the end of the body section:
Sys.Application.add_load(function () {
var module = angular.module('myModule');
var MasterController = function ($scope, $compile) {
... // stuffs
}
};
module.controller('MasterController', ["$scope", "$compile", MasterController]);
});
Everything seems to work fine locally without any errors in the console. However, when the application was deployed to a staging environment, an Angular error popped up in the browser console:
[ng:areq] not a function got undefined
Upon comparing the staging area with my local setup, the only notable differences are the use of .Net script bundler to concatenate and minify JS files, including Angular, and some data being used by the app. As far as I know, these are the only discrepancies.
I highly doubt the bundler is causing this issue since enabling bundling locally did not trigger the error. Additionally, the data being passed to the app, such as customer and account information, does not seem to be the cause as it is not even utilized in the specific controller where the problem occurs.