Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.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_Angular_Typescript_Local Storage_Angular Local Storage - Fatal编程技术网

Javascript 如何使用循环以表格形式打印Localstorage数组值?

Javascript 如何使用循环以表格形式打印Localstorage数组值?,javascript,angular,typescript,local-storage,angular-local-storage,Javascript,Angular,Typescript,Local Storage,Angular Local Storage,我将表单提交存储在localstorage key中,作为数组“fsubs”,如下所示: var fsubs = JSON.parse(localStorage.getItem('fsubs') || "[]"); var fcodes = {"barcodeno" : this.form.value.barcode, "reelno" : this.form.value.reelno, "width" : this.form.value.width, "dia" : this.form.val

我将表单提交存储在localstorage key中,作为数组“fsubs”,如下所示:

var fsubs = JSON.parse(localStorage.getItem('fsubs') || "[]");
var fcodes = {"barcodeno" : this.form.value.barcode, "reelno" : this.form.value.reelno, "width" : this.form.value.width, "dia" : this.form.value.dia, "weight" : this.form.value.weight};
fsubs.push(fcodes);
localStorage.setItem('fsubs', JSON.stringify(fsubs));
现在的问题是,我必须以表格形式打印这些值,比如使用循环,但我不知道怎么做

条形码|卷号
122121 | 232323

备注:我想在我的组件中使用Angular中的typescript打印此内容

组件1.ts:

fsubList:Array<any> = JSON.parse(localStorage.getItem('fsubs'));
fsubList:Array=JSON.parse(localStorage.getItem('fsubs'));
模板:

<table>
   <tr>
    <th>Barcode</th>
    <th>Reelno</th>
  </tr>
  <tr *ngFor="let item of fsubList">
    <td>{{item.barcodeno}}</td>
    <td>{{item.reelno}}</td>
  </tr>
</table>

条形码
里尔诺
{{item.barcodeno}
{{item.reelno}

我收到了这个错误
错误:Uncaught(承诺中):TypeError:JSON.Parse不是一个函数
console.log(localStorage.getItem('fsubs'))
并显示输出是
错误:Uncaught(承诺中):TypeError:JSON.Parse不是一个函数
它来自控制台,在解析中使用small
p
JSON.parse