我正在編寫我的代碼根據谷歌標準......甚至不知道這個語法是什麼調用,但它不同於控制器的Angular-UI示例代碼,我得到$ 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,
}
});
};
...
}]);
對話框打開罰款,但在用戶登錄後,但我得到的注射器錯誤這條線:
myApp.controller('LoginDialogCtrl', ['$scope', '$modalInstance', 'Auth', function($scope, $modalInstance, Auth) {
我已經測試過它這樣,它似乎工作,這實在是煩人:
var ModalInstanceCtrl = function ($scope, $modalInstance) {
$scope.ok = function() {
$modalInstance.close();
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
};
它是否與我的控制器被初始化的方式有關,並且在初始化時它不知道$ modalInstance?我如何完成這項工作?
您的myApp.controller不應該是myControllers.controller嗎? – miqid