I'm writing my code according to Google standards...not even sure what this syntax is called, but it's different from the Angular-UI example code for controllers and I'm getting an injector error for $modalInstance :(
var myControllers = angular.module('myControllers', ['ngCookies','ui.bootstrap']);
myApp.controller('LoginDialogCtrl', ['$scope', '$modalInstance', 'Auth', function($scope, $modalInstance, Auth) {
$scope.login = function() {
// Close dialog
$modalInstance.dismiss('Logged in');
};
}]);
myApp.controller('AuthCtrl', ['$scope', '$modal', 'Auth', function($scope, $modal, Auth) {
$scope.openLoginDialog = function () {
var modalInstance = $modal.open({
templateUrl: 'partials/auth/login.html',
controller: myApp.LoginDialogCtrl,
}
});
};
...
}]);
The dialog opens fine, but after the user logs in but I get an injector error for this line:
myApp.controller('LoginDialogCtrl', ['$scope', '$modalInstance', 'Auth', function($scope, $modalInstance, Auth) {
I have tested it like this and it seems to work which is really annoying:
var ModalInstanceCtrl = function ($scope, $modalInstance) {
$scope.ok = function () {
$modalInstance.close();
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
};
Does it have something to do with the way my controller is being initialized and at the time of it's initialization it doesn't know about $modalInstance? How do I make this work?