Jashka

Untitled

Sep 7th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. angular.module('Application', ['onsen', 'ngRoute'])
  2.     .config(['$compileProvider', function ($compileProvider) {
  3.         $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|tel):/);
  4.     }])
  5.     .config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
  6.         $routeProvider
  7.             .when('/', {
  8.                 controller: 'MainController',
  9.                 templateUrl: tplUrl + 'main/main.html'
  10.             })
  11.             .when('/users', {
  12.                 controller: 'UserController',
  13.                 templateUrl: tplUrl + 'user/user.html'
  14.             });
  15.  
  16.     }])
  17.     .controller('IndexController', function () {
  18.         var vm = this;
  19.  
  20.         vm.toggle = toggle;
  21.  
  22.         function toggle() {
  23.             menu.toggleMenu();
  24.         }
  25.     })
  26.     .factory('StorageFactory', function () {
  27.         return {
  28.             'set': function (key, value) {
  29.                 var data = null;
  30.                 if (angular.isArray(value) || angular.isObject(value)) {
  31.                     data = JSON.stringify(value);
  32.                 }
  33.  
  34.                 localStorage.setItem(key, data);
  35.             },
  36.             'get': function (key) {
  37.                 var data = localStorage.getItem(key);
  38.  
  39.                 if (data) {
  40.                     try {
  41.                         data = JSON.parse(data);
  42.                     } catch (e) {
  43.                     }
  44.  
  45.                     return data;
  46.                 } else {
  47.                     return null;
  48.                 }
  49.  
  50.             },
  51.             'rm': function (key) {
  52.                 localStorage.removeItem(key);
  53.             }
  54.         }
  55.     });
Add Comment
Please, Sign In to add comment