目录
经常能遇到需要对时间进行操作的需求,
1.根据开始时间 算出结束时间
Date starTime=new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(starTime);
calendar.add(Calendar.MONTH, 1);
return calendar.getTime();
2.angular中使用模态框
A.html 中有一个按钮,点击之后 弹出一个框B页面,同时把A页面的数据带到 B页面
首先是A页面的 按钮
<button ng-click="usingLastCostCenter()">
沿用上月目标 </button>
对应的js代码
app.controller("ACtr", function($scope,$modal ) {
$scope.copyotherEmpGoal = function(){
//需要带到模态框的数据id
var paramdata=$scope.param.objectiveId;
var modalInstance = $modal.open({
templateUrl: 'template/copyEmpGoalTarget_modal.html',
controller: 'copyEmpGoalTarget_modal_ctrl',
resolve: {
data: function () {
return paramdata;
}
}
});
}
})
接着你就在A页面最下面 写
<script type="text/ng-template" id="template/copyEmpGoalTarget_modal.html">
<div class="modal-header" >
<h4 class="modal-title">选择人员</h4>
</div>
<div class="modal-body" style="max-height: 500px; overflow: scroll">
<div >
B页面内容
</div>
</div>
<div class="modal-footer">
<button class="btn btn-default" ng-click="cancel()">取消</button>
<button class="btn btn-success" ng-click="submitEmp()">提交</button>
</div>
</script>
对应的js代码
app.controller("copyEmpGoalTarget_modal_ctrl", function($scope, call_api, $modalInstance,data) {
data 参数就是 传输过来的数据 id
$scope.submitEmp = function () {
$modalInstance.close({});
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
});