LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

  
    
    
    Ionic App

    
    
  

  
    
    
Box Value: {{myVar }}
Local Storage Value: {{ currentlyStored }}
CSS
#body-container {
  padding: 10px;
  margin: 40px 0 0 40px;
  border: 1px solid #CCCCCC;
}
#body-container span.val {
  color: #4C8CF5;
  font-weight: 900;
}
JS
'use strict';
angular.module('myApp', ['ionic'])

        .run(function($ionicPlatform) {
            $ionicPlatform.ready(function() {

            });
        })

.controller('myController', [
  '$scope',
  '$window',
            
  function($scope, $window) {
    
      // set initial values
      $scope.myVar = false;
      $scope.currentlyStored = "nothing is stored yet!";
      
      // set localStorage when function is called after a value is changed 
      $scope.updateStorage = function(){
        $window.localStorage['key'] = $scope.myVar;
        $scope.currentlyStored = $window.localStorage['key'];
      };
        

    }]);
Host Instantly Drag and Drop Website Builder

 

Description

An example showing how local storage can be used with Angular and Ionic.
Term
Mon, 11/27/2017 - 22:03

Related Codes

Pen ID
Pen ID
Pen ID