我有一个奇怪的问题,简单地将$ modal服务注入我的应用程序会导致ngGrid实例的奇怪行为 - ngCanvas(和包含的行)似乎认为它应该比包含元素短100px。
我的问题是:当注入$ modal服务时,它是否会以任何方式立即与DOM交互?我认为答案是肯定的,但我无法将其排除在源头之外。
编辑:使用angular-bootstrap 0.7.0,角度1.2.7
我如何使用$ modal和$ modalInstance:
的示例它存在于主控制器中以准备$ modal:
var modalOptions = {
dialogClass: 'modal admin-modal admin',
dialogFade: true,
backdropFade: true,
keyboard: true,
scope: $scope
};
$scope.unlockAccounts = function() {
var options = _.extend(modalOptions, {
templateUrl: '/admin/generic_users_modal.tpl.html',
controller: 'AccountUnlockModalController'
});
$modal.open(options).result.then(function(res) {
if(res) {
while($scope.selectedUsers.length) {
$scope.selectedUsers.pop();
}
}
});
};
这是模态控制器:
module.controller('AccountUnlockModalController', ['$scope', '$modalInstance', 'UserAPI', '$log', function($scope, $modalInstance, UserAPI, $log) {
$scope.templateConfig = {
description: 'unlock',
buttonText: 'Unlock accounts',
userPlurality: function() {
return $scope.selectedUsers && $scope.selectedUsers.length > 1 ? 'these accounts' : 'this account';
}
};
$scope.closeModal = function() {
// passing through false to clarify that no deselection should take place
$modalInstance.close(false);
};
$scope.modalFunction = function() {
var errs = [];
_.each($scope.selectedUsers, function(user) {
UserAPI.unlockAccount(user.email).then(function(res) {
if(res.status !== 200) {
errs.push(res);
}
})
});
if(errs.length) console.warn(errs);
// passing through false to clarify that users should be deselected
$modalInstance.close(true);
};
}]);
如果还有其他任何你想看的东西,我很乐意继续努力。谢谢!