【发布时间】:2021-11-29 14:34:25
【问题描述】:
我的组件是这样定义的:
import { Component } from 'angular2/core'
@Component({
selector: 'sidebar',
templateUrl: 'js/app/views/sidebar.html',
})
export class SidebarComponent {
public sections: boolean[] = [
true,
false,
false,
false,
false,
false,
false,
false
];
}
sidebar.html 模板:
<h3 class="proofTitle">...</h3>
<p [hidden]="sections[0]">
...
</p>
<p [hidden]="sections[1]">
...
</p>
...
<p [hidden]="sections[7]">
...
</p>
看起来很简单,但由于某种原因,它显示了所有部分......我错过了什么?
【问题讨论】:
-
你检查过隐藏属性是否被添加到DOM中的元素吗? (在开发工具中)
-
是的......而且我也发现了我的错误......
boolean array需要颠倒它的值...... duh
标签: angular