2016-08-23 55 views
1

當我在我的Angularjs中創建的應用程序中登錄後,第一步是初始功能顯示確認框。這是定期確認框,沒有任何風格。我的問題是如何風格化與CSS該框,並添加一些文字也一樣,如果我的功能是:角度確認框樣式

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; 
    }); 
    } 
} 

我再次提醒,我馬上開始登錄後此功能,無需按下按鈕或別的東西, ,自動。

有幫助嗎?

+0

我真的不知道如何添加類的,我現在就看 – Sasa

+0

重複的http://stackoverflow.com/questions/6185152/how-to-style-default-confirm-box-with-only -css – PeterS

+0

如果你需要風格化的模式,那麼看看bootstrap可以提供什麼。然而,你不會使用$ window.confirm。 – PeterS

回答

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'); 
      ); 
     } 
    ); 
} 

//---------------------------------------------------------------------------------------------------------------