2016-08-23 4 views
1

Nachdem ich mich in meiner App angemeldet habe, die ich in Angularjs gemacht habe, ist der erste Schritt, dass die erste Funktion zeigt Bestätigungsfeld. Das ist eine regelmäßige Bestätigungsbox, ohne Stil. Meine Frage ist, wie ich, dass das Feld mit CSS stilisieren kann, und fügen Sie auch einen Text, wenn meine Funktion:Eckige Bestätigungsbox Stil

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

Wieder werde mich daran erinnern, dass ich sofort mit dieser Funktion nach dem Login, ohne Druckknopf oder etwas anderes anfangen automatisch.

Irgendwelche Hilfen?

+0

ich über das Hinzufügen von Klasse nicht wirklich wissen, werde ich schauen jetzt – Sasa

+0

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

+0

Wenn Sie stilisierte Modale benötigen, dann schauen Sie, was Bootstrap bieten kann. Sie werden $ window.confirm jedoch nicht verwenden. – PeterS

Antwort

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

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