首先了解结果Angular2 ngFor

时间:2016-05-23 21:04:06

标签: arrays angular angular2-components

我有一个多维数组的数组:

<?php
class Socio {
    function Socio($rut, $nombre) 
    {
        $this->nombre = $nombre;
        $this->rut = $rut;
    }
}

$client = new SoapClient("theurl...");

$socio = new Socio(156371777, "Sebastian");

$params = array(
  "Cliente" => $socio,
);

$response = $client->__soapCall("Agregar", $params);

var_dump($response);

我想了解如何在一本书只有一章如“丛林书”或多次作为“名册”时创建一个* ngIf。

感谢您的帮助

1 个答案:

答案 0 :(得分:1)

我不确定我是否已完全了解选择科目。

无论如何,假设您要添加*ngIf检查的模板在定义books属性的同一组件中定义,我会尝试这样的事情

在模板中

<div *ngFor="let book of books">
  <div *ngIf="isBookToShow(book)">
    <!-- here goes the rest of your html -->
  </div>
</div>

使用类

中的相应方法isBookToShow(book)
isBookToShow(book) {
  return book.chapter.length > 0
}