Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从$localstorage检索变量_Javascript_Jquery_Angularjs_Local Storage_Bootstrap Table - Fatal编程技术网

Javascript 从$localstorage检索变量

Javascript 从$localstorage检索变量,javascript,jquery,angularjs,local-storage,bootstrap-table,Javascript,Jquery,Angularjs,Local Storage,Bootstrap Table,我在和ngStorage合作。我试图做的是将搜索保存到本地存储,并在刷新表后将其检索回来。 这是我的简单代码: js html 我的功能根本不起作用。如果有人能解释我的错误,我将不胜感激 ,您可以将localstorage中的值放入搜索bs表,但它不会触发。$scope.storage=$locastorage将整个$localstorage对象分配给变量。我不认为这是你想做的 要读取$localstoragedo的特定变量 $scope.storage.text = text; 此外,te

我在和ngStorage合作。我试图做的是将搜索保存到本地存储,并在刷新表后将其检索回来。 这是我的简单代码:

js

html

我的功能根本不起作用。如果有人能解释我的错误,我将不胜感激


,您可以将localstorage中的值放入搜索bs表,但它不会触发。

$scope.storage=$locastorage
将整个
$localstorage
对象分配给变量。我不认为这是你想做的

要读取
$localstorage
do的特定变量

$scope.storage.text = text;
此外,
text.push($scope.storage)
不会将任何内容分配给
$scope.storage
myarray.push(myvar)
myvar
添加到
myarray

将某物放入
$scope.storage
执行以下操作

$scope.storage.text = text;
  • $scope.storage=text
  • $scope.storage.mykey=text

$scope.storage=$locastorage
将整个
$localstorage
对象分配给变量。我不认为这是你想做的

要读取
$localstorage
do的特定变量

$scope.storage.text = text;
此外,
text.push($scope.storage)
不会将任何内容分配给
$scope.storage
myarray.push(myvar)
myvar
添加到
myarray

将某物放入
$scope.storage
执行以下操作

$scope.storage.text = text;
  • $scope.storage=text
  • $scope.storage.mykey=text

将文本保存到本地存储器

$scope.data = $scope.storage.text
而不是检索文本


将文本保存到本地存储器的步骤

$scope.data = $scope.storage.text
而不是检索文本


它返回:
TypeError:$scope.storage.push不是一个函数
似乎是正确的。我做了一些阅读:$scope.storage=$localstorage将整个本地存储推送到这个变量中。请尝试
$scope.storage=text
它返回:
TypeError:$scope.storage.push不是一个函数
似乎是正确的。我做了一些阅读:$scope.storage=$localstorage将整个本地存储推送到这个变量中。请尝试
$scope.storage=text
文本正在检索,问题是我无法将此文本推回搜索是否尝试了text.push($scope.storage.text);如果我使用$scope.storage.text,它会告诉我文本未定义。是否将文本保存到storage.text?你必须保存文本才能加载它,我的搜索代码是什么意思?它是bs表格的一部分,并通过此函数内的
text
(“#table”).on('search.bs.table',函数(e,text){})您可以找到文本正在检索的搜索值,问题是我无法将此文本推回搜索您是否尝试了text.push($scope.storage.text);如果我使用$scope.storage.text,它会告诉我文本未定义。是否将文本保存到storage.text?你必须保存文本才能加载它,我的搜索代码是什么意思?它是bs表格的一部分,并通过此函数内的
text
(“#table”).on('search.bs.table',函数(e,text){})您可以找到搜索值