如何从txt文件采用了棱角分明的js推动所有值到本地存储 [英] how to push all values from the txt file to local storage using angular js

查看:193
本文介绍了如何从txt文件采用了棱角分明的js推动所有值到本地存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,当用户点击按钮地方可以存储值到本地存储的示例应用程序,但我想从txt文件的所有值要在本地存储注2:[]

I have a sample application which can store values into local storage when user clicks to local button but i want to all values from the txt file to be in local storage "note2": [] .

Plunker演示

推荐答案

是的,我找到了一种方法来做到这一点。

And yes i found a way to do so .,

您可以使用 NG-的init ='函数名'

在这里,我用一个功能,当用户点击本地按钮将值推到本地

here i use a function when a user click the to local button to push a value to local

$scope.cloneItem = function (todo) {
        $scope.$storage.notes.push({
            "price": todo.price,
            "id": todo.id,
            "quan": todo.quan
        });
    }

但我想所有的值存储在TXT文件下载到本地,所以我用

but i want to store all the values from the txt file to local so i use

ng-init='your js function name' 

此函数来调用推送功能,使每NG-重复值将推动当地的

this function to call push function so that for every ng-repeat the value would push to local

例如:

<tr ng-repeat="todo in todos" ng-init='cloneItem(todo)'>

这篇关于如何从txt文件采用了棱角分明的js推动所有值到本地存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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