NG-重复过对象的数组 [英] ng-repeat over an array of objects
本文介绍了NG-重复过对象的数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用NG重复,我将如何通过循环以下内容:
Using ng-repeat, how would I loop through the following:
var messages : [
{text:"Standard Message"},
{text:"Success Message!", type:"success"},
{text:"Alert Message!", type : "alert"},
{text:"secondary message...", type : "secondary"}
]
我试过:
<p ng-repeat="message in messages">{{message}}</p>
和它似乎并没有工作,我会怎么做呢?
and it doesn't seem to work, how would I do this?
推荐答案
您需要将您的信息阵列到$范围:
You need to insert your messages array into the $scope:
$scope.messages = [
{text:"Standard Message"},
{text:"Success Message!", type:"success"},
{text:"Alert Message!", type : "alert"},
{text:"secondary message...", type : "secondary"}
]
,然后用它如下:
and then use it as following:
<p ng-repeat="message in messages">{{message.text}}</p>
这篇关于NG-重复过对象的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文