Created
July 27, 2016 13:52
-
-
Save omariosouto/040d30c13a07745c577e1c4e0d85cbc7 to your computer and use it in GitHub Desktop.
angular-cache
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>Angular APP</title> | |
| <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-cache/4.6.0/angular-cache.min.js"></script> | |
| </head> | |
| <body> | |
| <div ng-app="myApp" ng-controller="myCtrl"> | |
| <p>Today's welcome message is:</p> | |
| <ul> | |
| <li ng-repeat=" posts in myWelcome "> | |
| {{ posts.name }} | |
| </li> | |
| </ul> | |
| </div> | |
| <script> | |
| var app = angular.module('myApp', []); | |
| app.controller('myCtrl', function($scope, $http) { | |
| var urlGet = "http://jsonplaceholder.typicode.com/comments?postId=1"; | |
| $http.get(urlGet, { cache: true }) | |
| .then(function(response) { | |
| $scope.myWelcome = response.data; | |
| window.localStorage[urlGet] = angular.toJson(response.data); | |
| }); | |
| var accessData = window.localStorage[urlGet]; | |
| console.log(urlGet+":"+ accessData); | |
| console.log(window.localStorage); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment