最近我正在学习angularjs.我以前用过bootstrap.使用jquery,我可以轻松更改模态组件位置的位置,使其垂直对齐.现在有了angularjs,这似乎并不容易.这是一个ui bootstrap模式的plunker链接,有谁知道如何使它垂直对齐?
1.index.html
<!doctype html>
<html ng-app="ui.bootstrap.demo">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.2.1.js"></script>
<script src="example.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div ng-controller="ModalDemoCtrl">
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-header">
<h3 class="modal-title">I'm a modal!</h3>
</div>
<div class="modal-body">
This is modal body
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
<button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
</div>
</script>
<button type="button" class="btn btn-default" ng-click="open()">Open me!</button>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
2.example.js
angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('ModalDemoCtrl', function($scope, $uibModal, $log) {
$scope.items = ['item1', 'item2', 'item3'];
$scope.animationsEnabled …Run Code Online (Sandbox Code Playgroud) 最近我使用的是新发布的mongodb java异步驱动程序.我正在写一些简单的测试代码,它们是:
MongoClient mongoClient = MongoClients.create();
System.out.println("database has been connected!");
SingleResultCallback<Void> callbackWhenFinished = new SingleResultCallback<Void>() {
@Override
public void onResult(final Void result, final Throwable t) {
System.out.println("Operation Finished!");
}
};
mongoClient.listDatabaseNames().forEach(new Block<String>() {
@Override
public void apply(final String s) {
System.out.println(s);
}
}, callbackWhenFinished);
Run Code Online (Sandbox Code Playgroud)
但是,没有调用回调函数,控制台输出是:
2015年4月18日下午10:50:27 com.mongodb.diagnostics.logging.JULLogger日志消息:使用设置创建的集群{hosts = [localhost:27017],mode = SINGLE,requiredClusterType = UNKNOWN,serverSelectionTimeout ='30000 ms', maxWaitQueueSize = 500}
数据库已连接! 2015年4月18日下午10:50:28 com.mongodb.diagnostics.logging.JULLogger日志消息:ReadPreferenceServerSelector {readPreference = primary}从集群描述ClusterDescription中选择的服务器 {type = UNKNOWN,connectionMode = SINGLE,all = [ServerDescription { address = localhost:27017,type = UNKNOWN,state = …