This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Offline Angular Form Tutorial</title> | |
| </head> | |
| <body data-ng-app="app"> | |
| <div data-ng-controller="MainController"> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('app', []) | |
| .controller('MainController', ['$scope', function ($scope) { | |
| }]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Offline Angular Form Tutorial</title> | |
| </head> | |
| <body data-ng-app="app"> | |
| <div data-ng-controller="MainController"> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('app', []) | |
| .controller('MainController', ['$scope', function ($scope) { | |
| $scope.formData = {}; | |
| //Parses and saves to localStorage | |
| $scope.save = function () {}; | |
| //Once connection is detected, submit to server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Parses and saves to localStorage | |
| $scope.save = function () { | |
| var stringCopy = ''; | |
| //lc only accepts strings | |
| //allows us to reference this lc record later | |
| $scope.formData.lcKey = Date.now().toString(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Once connection is detected, submit to server | |
| $scope.sync = function () { | |
| var records = fetchAll(); | |
| //if connection exists | |
| if (navigator && navigator.onLine && records.length) { | |
| records.forEach(function (find, idx) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var fetchAll = function () { | |
| var finds = []; | |
| if (localStorage.length === 0) { | |
| return []; | |
| } | |
| for (var i=0;i<localStorage.length;i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <button type="submit">Save Locally</button> | |
| <button type="button" data-ng-click="sync()">Sync</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('app', []) | |
| .controller('MainController', ['$scope', function ($scope) { | |
| var fetchAll = function () { | |
| var finds = []; | |
| if (localStorage.length === 0) { | |
| return []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Offline Angular Form Tutorial</title> | |
| </head> | |
| <body data-ng-app="app"> | |
| <div data-ng-controller="MainController"> | |
OlderNewer