use*_*325 3 angularjs angular-ui-bootstrap
我在plunkur有以下示例 点击这里打开链接
var app = angular.module('App', ['ui.bootstrap']);
try {
app.service('loginModalService', function ($modal, $rootScope) {
function assignCurrentUser(user) {
$rootScope.currentUser = user;
return user;
}
return function () {
var instance = $modal.open({
templateUrl: 'loginModalTemplate.html',
controller: 'LoginModalCtrl',
controllerAs: 'LoginModalCtrl',
windowClass: 'vertical-center',
backdrop: true,
backdrop: 'static',
sticky: true
})
return instance.result.then(assignCurrentUser);
};
});
} catch (e) {
alert("Error --- " + e.message);
}
//UsersAPI is service to validate on server
app.controller('LoginModalCtrl', function ($scope, loginModalService) {
this.cancel = $scope.$dismiss;
$scope.showModal = function () {
loginModalService()
.then(function () {
alert("OK Selected ");
//return $state.go(toState.name, toParams);
})
.catch(function () {
console.log("User Cancelled Login hence Navigation Cancelled ");
//return $state.go('home');
});
}
this.submit = function (email, password) {
// UsersApi.login(email, password).then(function (user) {
// $scope.$close(user);
// });
$scope.$close("abc");
};
});
Run Code Online (Sandbox Code Playgroud)
我无法使用淡入淡出尝试灰色背景.如果我将淡入淡出添加到类中,则模态不会打开
我错过了什么?
另外,为什么不在屏幕中央显示自己?
jme*_*e11 17
在Bootstrap 3.3.1中,修改了.modal-backdrop CSS属性.这种变化导致模态背景具有绝对定位,而不是固定定位而没有底部属性设置.Bootstrap JS文件不是使用bottom属性,而是注入内联样式,将模态背景的高度设置为视口的高度.UI-Bootstrap 0.12.0中的模态服务不会在模态背景上注入高度,因此背景就在那里,但它没有高度,你也看不到它.
有两种方法可以解决这个问题:
CSS:
.modal-backdrop {
bottom:0;
}
Run Code Online (Sandbox Code Playgroud)
要回答关于如何在窗口中垂直居中模式的第二个问题,您可以使用一些自定义CSS来完成此操作.仅供参考,这种方法基于CSS转换,因此在IE8中不受支持,并且仅在带有-ms-前缀的IE9中受支持.
.modal.fade .modal-dialog, .modal.in .modal-dialog {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
}
.modal-content {
position: absolute;
top:50%;
-ms-transform: translate(0,-50%);
-moz-transform: translate(0,-50%);
-webkit-transform: translate(0,-50%);
transform: translate(0,-50%);
width:100%;
}
Run Code Online (Sandbox Code Playgroud)
在更新的演示中,我使用了您的代码,除了我稍微修改了模板并将其添加到模板缓存中.
| 归档时间: |
|
| 查看次数: |
4746 次 |
| 最近记录: |