Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何将角度分量输出提取到外部div_Html_Angular_Typescript_Angular Components_Angular Template - Fatal编程技术网

Html 如何将角度分量输出提取到外部div

Html 如何将角度分量输出提取到外部div,html,angular,typescript,angular-components,angular-template,Html,Angular,Typescript,Angular Components,Angular Template,我希望显示不同的列表(由组件定义),但仅当子组件生成必要的输出时才显示其标题 假设我有一个组件,其中,@Output是一个事件,如下所示 export class ItemListComponent implements OnInit { @Input() private filter: (t: Item) => boolean; private tasks: TaskItem[]; @Output() isEmpty = new EventEmitter();

我希望显示不同的列表(由组件定义),但仅当子组件生成必要的
输出时才显示其标题

假设我有一个组件,其中,
@Output
是一个事件,如下所示

export class ItemListComponent implements OnInit {

  @Input()
  private filter: (t: Item) => boolean;

  private tasks: TaskItem[];

  @Output()
  isEmpty = new EventEmitter();
在我的另一个组件中,我通过注入必要的
过滤器来显示此列表,如下所示

列表标题

我可以根据
(isEmpty)
隐藏项目列表,但是我可以隐藏上面的
div
吗?

您可以使用
.parent.ts
中的变量来隐藏和显示您的
div

item-list.component.ts

export class ItemListComponent implements OnInit {

  @Input()
  private filter: (t: Item) => boolean;

  private tasks: TaskItem[];

  @Output()
  isEmpty = new EventEmitter(Boolean);
.parent.html

<div *ngIf="isShow"> list header  <-- I would love to hide that -->
<app-item-list [filter]="filter" *ngIf="!(isEmpty)" (isEmpty)="myFunc(e)">
</app-item-list>
</div>

您可以使用
.parent.ts
中的变量来隐藏和显示您的
div

item-list.component.ts

export class ItemListComponent implements OnInit {

  @Input()
  private filter: (t: Item) => boolean;

  private tasks: TaskItem[];

  @Output()
  isEmpty = new EventEmitter(Boolean);
.parent.html

<div *ngIf="isShow"> list header  <-- I would love to hide that -->
<app-item-list [filter]="filter" *ngIf="!(isEmpty)" (isEmpty)="myFunc(e)">
</app-item-list>
</div>

您可以使用“ng容器”,而不是使用“div”

<ng-container*ngIf="isShow"> list header  <-- I would love to hide that -->
<app-item-list [filter]="filter" *ngIf="!(isEmpty)" (isEmpty)="myFunc(e)">
</app-item-list>
</ng-container>
列表标题

您可以使用“ng容器”,而不是使用“div”

<ng-container*ngIf="isShow"> list header  <-- I would love to hide that -->
<app-item-list [filter]="filter" *ngIf="!(isEmpty)" (isEmpty)="myFunc(e)">
</app-item-list>
</ng-container>
列表标题

当您想隐藏div时,请在stackblitz上重现该问题。这有助于贡献者帮助您。当您想隐藏div时,请在stackblitz上复制该问题。它帮助贡献者帮助你。