diagnostic_module.controller("SpeakerCtrler", ["$scope", "$http", function ($scope, $http) {
$scope.isTesting = false;
$scope.$on('$locationChangeStart', function( event ) {
var answer = confirm("Are you sure you want to leave this page?")
if (!answer) {
event.preventDefault();
}
else
{
if($scope.isTesting)
{
$http.delete('/api/diagnostics/speaker').
success(function () {
$scope.isTesting = false;
});
}
}
});
$scope.onStartSubmit = function() {
$http.post('/api/diagnostics/speaker').
success(function () {
$scope.isTesting = true;
});
};
$scope.onStopSubmit = function() {
$http.delete('/api/diagnostics/speaker').
success(function () {
$scope.isTesting = false;
});
};
}]);
Confirmation on Leaving the Current Page in an Angular.js App
最新推荐文章于 2020-08-26 16:13:34 发布