使用angularjs将数据保存在json本地存储中 [英] save data in json local storage with angularjs

查看:315
本文介绍了使用angularjs将数据保存在json本地存储中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这张表格

<form ng-submit="addState()">
            <input ng-model="text1" type="text">
            <input ng-model="text2" type="text">
            <input ng-model="text3" type="text">     
</form>

和这个JS

mainAppControllers.controller('DoarScanCtrl', ['$scope', '$routeParams', '$location',
    function($scope, $routeParams, $location){

    }
]);

所以首先我需要将数据保存在本地存储中,然后再需要一个json

So First i need save the data in local storage and after this i need have a json

谢谢您的帮助!

推荐答案

我建议使用此lib https ://github.com/grevory/angular-local-storage 还将对象和数组自动转换为json

I would recommend this lib https://github.com/grevory/angular-local-storage it also auto convert object and array to json

localStorageService.set("model", $scope.model);

$scope.model2= localStorageService.get("model");

我摆弄了如何使用 http://jsfiddle.net/jgs4280c/

这篇关于使用angularjs将数据保存在json本地存储中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆