Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (31 sloc) 1.13 KB
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1">
<title>simple</title>
</head>
<body ng-app="app" ng-controller="MainCtrl">
<script src="/simple/angular.min.js"></script>
<script>
var app = angular.module('app', []);
app.controller('MainCtrl', function($scope, $http) {
$scope.isSupportServiceWorker = false;
$scope.isOnline = false;
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/simple/sw.js').then(function(registration) {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
$scope.$apply(function() {
$scope.isSupportServiceWorker = true;
});
}).catch(function(err) {
console.log('ServiceWorker registration failed: ', err);
});
}
$http.get('/online').then(success => {
$scope.isOnline = true;
}).catch();
});
</script>
<div>isSupportServiceWorker: {{isSupportServiceWorker}}<div>
<div>isOnline: {{isOnline}}<div>
</body>
</html>