Angular confirmation box style

a 夏天 提交于 2020-01-15 04:15:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!