【问题标题】:how to get the values from ngStorage如何从 ngStorage 获取值
【发布时间】:2015-05-27 14:50:44
【问题描述】:

如何使用angularjs中的ng stroage模块从浏览器获取本地存储的json值

我使用$scope.data = $localStorage.notes;

 <div class="col-xs-6 well">
  {{data}}
 </div>

但是json值越来越我只想要文本值

Demo

【问题讨论】:

  • 你检查过一些关于它的链接吗? blog.nraboy.com/2014/12/…teamtreehouse.com/forum/…
  • @trainoasis 我检查了 teamtreehouse 但他们的 plunker 不工作
  • @trainoasis 我得到了 json 值,但我只想要 json 数据中的文本值。我更新了我的 plunker
  • @trainoasis 我明白了..感谢您的支持..

标签: json angularjs local-storage ng-storage


【解决方案1】:

如果您只想要文本值,请使用. 表示法获取它们

        <div class="col-xs-6 well">
        <ul class="unstyled">
            <li data-ng-repeat="item in data">

                <span class="h1">id:{{ item.id }} age:{{ item.age }}</span>
            </li>
        </ul>
    </div>

更新plnkr

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2015-09-09
  • 2012-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-11
相关资源
最近更新 更多