Whenever I attempt to connect a controller to a template using the angular-ui-router $stateProvider, I encounter this error message:
'ShouldWorkController' is not a function. Got undefined.
Surprisingly, when I define the controller within the template using ng-controller, everything functions properly. What could be causing this issue?
app.ts
module App {
var dependencies = [
MyControllers
]
function configuration($stateProvider: ng.ui.IStateProvider) {
$stateProvider
.state("shouldWork", {
url: "/shouldWork",
templateUrl: "app/shouldWork.html"
controller: "ShouldWorkController" // has issues working
});
}
}
shouldWorkController.ts
module App.MyControllers {
interface IShouldWorkViewModel {
}
class ShouldWorkController implements IShouldWorkViewModel {}
}
ShouldWork.html
<div ng-controller="ShouldWorkController as viewModel" us-spinner spinner-key="spinner-1">
^ --- this operates smoothly