By default your HTTP requests with the $https service in Angular are not cached. By setting some options, you can turn caching on.
/** * Created by Answer1215 on 12/15/2014. */angular.module('app', ['ngMaterial']) .controller('MainCtrl', function(BookmarksService, BookmarksCacheFactory) { var mainCtrl = this; mainCtrl.bookmarks = []; mainCtrl.getBookmarks = function() { BookmarksService.getBookmarks().then(function(response) { mainCtrl.bookmarks = response.data; }); } mainCtrl.removeCache = function() { BookmarksCacheFactory.remove('./data/bookmarks.json'); } }) .service('BookmarksService', function($http, BookmarksCacheFactory) { var BookmarksService = {}; BookmarksService.getBookmarks = function() { return $http.get('./data/bookmarks.json', {cache: BookmarksCacheFactory}); } return BookmarksService; }) .factory('BookmarksCacheFactory', function($cacheFactory) { return $cacheFactory('bookmarks'); });
{ {b.title}}Load Bookmarks Clear cache
"Load bookmarks" only work for the first time clicking the button and load the data.
After click "clear cache", then will load data again.