gpt4 book ai didi

javascript - 使用 angular-modal-service (AngularJS) 自定义模式

转载 作者:太空狗 更新时间:2023-10-29 15:13:16 25 4
gpt4 key购买 nike

我正在使用 ( angular-modal-service ) 通过服务创建弹出窗口和模式,但我想知道如何自定义它们?例如,如何更改 modal-header 颜色或删除页眉、正文和页脚之间的“默认”行?谢谢。

Controller 示例:

var app = angular.module('app', ['angularModalService']);

app.controller('Controller', function($scope, ModalService) {

$scope.show = function() {
ModalService.showModal({
templateUrl: 'modal.html',
controller: "ModalController"
}).then(function(modal) {
modal.element.modal();
modal.close.then(function(result) {
$scope.message = "You said " + result;
});
});
};

});

app.controller('ModalController', function($scope, close) {

$scope.close = function(result) {
close(result, 500); // close, but give 500ms for bootstrap to animate
};

});

html 示例:

<script src="https://code.angularjs.org/1.4.9/angular.min.js"></script>
<script src="https://rawgit.com/dwmkerr/angular-modal-service/master/dst/angular-modal-service.js"></script>

<div class="container" ng-app="app" ng-controller="Controller">

<h3>Angular Modal Service</h3>
<a class="btn btn-default" href ng-click="show()">Show a Modal</a>
<p>{{message}}</p>

<!-- The actual modal template, just a bit o bootstrap -->
<script type="text/ng-template" id="modal.html">
<div class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" ng-click="close('Cancel')" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Yes or No?</h4>
</div>
<div class="modal-body">
<p>It's your call...</p>
</div>
<div class="modal-footer">
<button type="button" ng-click="close('No')" class="btn btn-default" data-dismiss="modal">No</button>
<button type="button" ng-click="close('Yes')" class="btn btn-primary" data-dismiss="modal">Yes</button>
</div>
</div>
</div>
</div>
</script>

</div>

最佳答案

你的问题是 CSS 问题。

要更改模态颜色或边框,您必须添加自定义 CSS。

您可以使用 google dev 工具更改样式并实时查看结果,这样您就不必重新加载页面。

更改标题颜色:

.modal-header {
background-color: red;
}

在页脚中隐藏边框:

.modal-footer {
border-top: 0px!important;
}

关于javascript - 使用 angular-modal-service (AngularJS) 自定义模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36668627/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com