Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49076

Save a list in local storage

$
0
0

@KavDeesh wrote:

Hi,
The project I'm working on has 2 pages.
Page 1 - You can set a number (Ex: Numb = 4)
Page 2 - Controller will automatically generates 4 list items with a name.
( 1 - This is list item one
2 - You can change the list item name
3 - This is list item three
4 - These can be edited)
Page 3 - Once you click on a page, you will be redirect to another page which has the full content of the list item

Here's the problem.
I'm trying to save the list in to local storage. Where I'm having a trouble is, passing multiple objects in to the controller. This is the controller I used for this.

//SaveController
    .controller("SaveController", function($scope){
        $scope.saveData = function(v){
            window.localStorage.setItem("data", v);
        }
        $scope.loadData = function(){
            alert(window.localStorage.getItem("data"));
        }
    })

.

<!--view-->
<div ng-controller="SaveController">
    <button class="button" ng-click="saveData(singleVatiable)">Save</button>
    <button class="button" ng-click="loadData()">Load</button>
</div>

I want a way to replace 'singleVariable' with an array!

Thanks!

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 49076

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>