[英]ng-repeat angular array objects
I have a problem. 我有个问题。 I need to show the information returned by a service that I am using.
我需要显示我正在使用的服务返回的信息。
Service returns me: 服务返回我:
Object {resultado:array[2], mensaje: "4 personas `necesita tu ayuda"}
Now in "resultado" returns me a object with two arrays. 现在在“ resultado”中返回一个带有两个数组的对象。
resultado
object 0 {id_persona : 1, nombre: Miguel, apellido: Gonzalez.....}
object 1 {id_persona : 1, nombre: Miguel, apellido: Gonzalez.....}
I need to use ng-repeat in the next list: 我需要在下一个列表中使用ng-repeat:
<div id="request-uptutor" class="background-uptutor">
<div id="header-home"></div>
<div id="home-alert">
<h4 class="type-text-list5 type-font3 type-text-color5-titulos">{{dataRequest.mensaje}}</h4>
</div>
<h5 class="type-font3 type-text-list5 type-text-color6" style="margin-left:20px;">Tutorías solicitadas</h4>
<div class="lists list-image">
<ul>
<li ng-repeat="">
<img src="assets/img/images.jpg" class="img-circle list-blocks">
<div class="information-class list-blocks">
<span class="type-text-list1">Mateo Martinez</span><br>
<span class="type-text-list2 type-text-color5-titulos">Universidad ICESI</span><br>
<span class="type-text-list3 type-text-color2">16 de diciembre de 2015 | 13:00-15:00 Grupal(4 personas)</span>
</div>
<div class="datatime-class list-blocks" style="float:right !important;">
<span class="type-text-list5 type-font3 type-text-color5-titulos">$30,000</span><br>
<div class="btn-ok icon-confirmation"></div>
<div class="btn-cancel icon-confirmation"></div>
</div>
</li>
</ul>
</div>
But, I do not know how to do it. 但是,我不知道该怎么做。
have already declared the controller, now I need to know how to capture the object with the "X" arrays used to bring me and ng-repeat for iterarlos 已经声明了控制器,现在我需要知道如何使用用于带给我和ng-repeat的iterarlos的“ X”数组捕获对象
I just need an example to me the idea, and I applied it to my controller. 我只需要一个例子就可以了,然后将其应用于我的控制器。 I thank you very much.
我非常感谢你。
something like this? 这样的东西? - I have no idea where you want to show the field values, but you can put them in the double curly braces:
-我不知道您想在哪里显示字段值,但是可以将它们放在双花括号中:
<li ng-repeat="result in obj.resultado">
<img src="assets/img/images.jpg" class="img-circle list-blocks">
<div class="information-class list-blocks">
<span class="type-text-list1">{{result.nombre}}</span><br>
<span class="type-text-list2 type-text-color5-titulos">Universidad ICESI</span><br>
<span class="type-text-list3 type-text-color2">16 de diciembre de 2015 | 13:00-15:00 Grupal(4 personas)</span>
</div>
<div class="datatime-class list-blocks" style="float:right !important;">
<span class="type-text-list5 type-font3 type-text-color5-titulos">$30,000</span><br>
<div class="btn-ok icon-confirmation"></div>
<div class="btn-cancel icon-confirmation"></div>
</div>
</li>
To achieve what you're trying to do simply do as follow: 要实现您想要做的事情,只需执行以下操作:
<div id="request-uptutor" class="background-uptutor">
<div id="header-home"></div>
<div id="home-alert">
<h4 class="type-text-list5 type-font3 type-text-color5-titulos">{{dataRequest.mensaje}}</h4>
</div>
<h5 class="type-font3 type-text-list5 type-text-color6" style="margin-left:20px;">Tutorías solicitadas</h4>
<div class="lists list-image">
<ul>
<li ng-repeat="person in obj.resultado">
<img src="assets/img/images.jpg" class="img-circle list-blocks">
<div class="information-class list-blocks">
<span class="type-text-list1">{{person.nombre}}{{person.apellido}}</span><br>
<span class="type-text-list2 type-text-color5-titulos">{{person.universidad}}</span><br>
<span class="type-text-list3 type-text-color2">16 de diciembre de 2015 | 13:00-15:00 Grupal(4 personas)</span>
</div>
<div class="datatime-class list-blocks" style="float:right !important;">
<span class="type-text-list5 type-font3 type-text-color5-titulos">$30,000</span><br>
<div class="btn-ok icon-confirmation"></div>
<div class="btn-cancel icon-confirmation"></div>
</div>
</li>
</ul>
</div>
To make this even fancier, add a filter ng-repeat="person in obj.resultado | filter: textoBusqueda"
. 为了使它更加
ng-repeat="person in obj.resultado | filter: textoBusqueda"
添加一个过滤器ng-repeat="person in obj.resultado | filter: textoBusqueda"
。
Then just add another input field <input placeholder="Busqueda" ng-model="textoBusqueda"></input>
然后只需添加另一个输入字段
<input placeholder="Busqueda" ng-model="textoBusqueda"></input>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.