问题
After I login in my app which I made in Angularjs, first step is that initial function show confirmation box. That is regular confirmation box, without any style. My question is how I can stylize that box with CSS, and add some text too, if my function is :
function versionCheck() {
if ($window.confirm("Are you sure?")) {
vm.starting = true;
dataService.restartVersion()
.then(function onSuccess(data) {
vm.data = data.response;
}).catch(function onReject(response) {
}).finally(function () {
vm.starting = false;
});
}
}
Again I will remind that I immediately start with this function after login, without press button or something else, automatically.
Any helps?
回答1:
//---------------------------------------------------------------------------------------------------------------
# This is the Angular Material Design way of customizing dialog boxes.
# $mdDialog.confirm() and $mdDialog.show will solve this issue.
# I would create a totally different function to handle the dataService
# And have the versionCheck() just handling the confirmation dialog
# as shown below.
function versionCheck() {
var confirm = $mdDialog.confirm()
.title('Cancel confirmation')
.textContent('Are you sure?')
.ariaLabel('Are you sure?')
.ok('Ok')
.cancel('Cancel');
$mdDialog.show(confirm).then(
function() {
$state.go('login');
);
}
);
}
//---------------------------------------------------------------------------------------------------------------
来源:https://stackoverflow.com/questions/39103826/angular-confirmation-box-style