我在努力清理我的模板代码。我有以下几点:
<ul>
<li *ngIf="condition" *ngFor="let a of array1">
<p>{{a.firstname}}</p>
<p>{{a.lastname}}</p>
</li>
<li *ngIf="!condition" *ngFor="let b of array2">
<p>{{b.firstname}}<
这个问题类似于,但这里没有明确的答案,它与反应有关,而不是角度,所以答案可能会有所不同。本质上,问题是“从DOM中添加/删除元素比显示/隐藏元素更可取吗?”给予:
<app-parent>
Zero or one of many child components displayed here.
</app-parent>
如果每个孩子都以一种方式包装自己,那么:
<app-modal visible="isVisible"> Child n's content here </app-modal>
这两种方法中哪一种
我有一个Angular应用程序,在一些界面中,我需要根据从我的数据库中检索到的用户配置来显示/隐藏一些div。
我在考虑使用*ngIf并这样做:
<div *ngIf=“hasConfig(‘blue’)>
Blue div
</div>
<div *ngIf=“hasConfig(‘yellow’)>
Yellow div
</div>
<div *ngIf=“hasConfig(‘red’)>
Red div
</div>
但我担心这会损害我的应用程序的性能,让我的应用程序变得有
只有在用户登录时满足条件时,我才希望在模板中显示页面。我使用了ngIf*但是我不知道我必须把它放在哪里,不管是在路由页面还是组件的页面中。
我尝试过一个代码:页面仍然显示在模板的菜单中,只有它的内容是隐藏的。另外,我也有一个错误
错误:无法找到加载“布局”的主出口--这是代码
import { Component, Input } from '@angular/core';
import { user } from './forms/user';
@Component({
selector: 'forms',
tem