简体   繁体   English

AngularJS ngRepeat循环变量

[英]AngularJS ngRepeat loop variables

I have the following code: 我有以下代码:

 $scope.links = { 
            home: {text:'Home', link:'#'},
            about: {text:'Contact', link:'#'},
            handeMade: {text:'Contact', link:'#'},
            shirts: {text:'Contact', link:'#'},
            design: {text:'Contact', link:'#'},
            photography: {text:'Contact', link:'#'},
            blog: {text:'Contact', link:'#'},
            contact: {text:'Contact', link:'#'}
        }

I want to loop the variable inside the scope links using the directive ngRepeat to get the text and the link of each object, is it possible to do that? 我想使用指令ngRepeat在作用域链接内循环变量以获取文本和每个对象的链接,可以这样做吗?

Thanks. 谢谢。

See how this works: 看看这是如何工作的:

<div ng-repeat="link in links track by $index">
    <p>Text: {{link.text}}</p>
    <p>Link: {{link.link}}</p>
</div>
<div ng-repeat="(key,value) in links">
  <div ng-repeat="(k,v) in value">
     <p>Text: {{k.text}}</p>
     <p>Link: {{k.link}}</p>
   </div>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM