我正在创建一个调度程序/日历,但我必须从头开始构建自己的日历。
我每个月都有很多天。例如,5月: 31天。现在我想将这个数组划分为几个星期,然后使用一个表来显示。(就像日历)
请考虑到,稍后,我将不得不使这些‘天’点击,以便能够执行进一步的行动。
我尝试了什么:
我尝试做一个嵌套数组weeksweek_number。但是,当试图显示日期时,下面的代码根本不起作用。什么都没显示出来。
<tr *ngFor="let week of weeks; let i = index">
<td *ngFor="let day of week.days; let j
我有一个组件,它订阅一些用于填充表的数据。这个表使用*ngFor循环数据数组,并将其输出到页面,这是典型的内容。
当我像so importResults: ImportResults[];一样定义数组时,我的数据似乎会按预期的方式存储,并留下一个对象数组。
ngOnInit() {
// Subscribe to our subject that lets us know about the added employees
this._massEmpService.importedData.subscribe(obj => {
if (obj) {
我在从JSON对象显示动态表时遇到了问题。我有两个数组。一个数组包含表的头部,另一个数组包含JSON,objects.The的问题是,我希望按每个JSON对象的头数组值顺序显示数据(每个对象都被视为行)。我试图显示数据的代码是:
<table id="myTable">
<tr >
<th *ngFor="let head of FilteredKeys;let i =index" (click)="sortTable(i)">{{head}}</th>
</t
我目前在一个项目中工作,这需要我填充一个动态数量的按钮与浸泡的链接,以打开它们。 <tr *ngFor="let competence of competences; let i = index">{{competence.name.de}}
<td *ngFor="let competenceLevel of levels; let j = index">
<button type="button" *ngFor="let learnRecommendation of getLearnReco
我已经创建了一个HTML-表格的角度。行将像
<tr mdbTableCol *ngFor="let el of filteredElements;">
<td align="right">{{el.totalExpenses | number : '.2-2'}}</td>
当我刷新数组filteredElements中的元素时,视图不会更新。下面是我刷新Array的代码:
this.filteredElements[this.filteredElements.findIndex(el => e
*ngFor使我的应用程序非常慢,因为有上千行迭代。除了性能缓慢外,它的工作方式与预期的一样。如果select或input值被更改,其值将为红色。如果_main.rolls被迭代,我可以获取所有修改过的值,并将它们发送到API以进行更新。
<tr *ngFor="let student of _main.students"> <!-- up to 250 students (rows). -->
<ng-container *ngFor="let date of _main.attendance_dates"> <
我在一个角度应用程序中使用一个Redux来保存应用程序状态。
但在我看来,我想将这个Redux存储状态分配给一个可观察到的$变量,这个角度视图可以绑定到这个变量,并随着状态的变化而更新。
import { of } from 'rxjs';
.....
// Using RxJS operator to cast Redux store state to an Observable
public viewData: any[] = [];
this.viewData$ = of(this.store.getState());
但是,当我试图将viewData绑定到ngFor
我有一个具有特定ids的行列表:
<li *ngFor="let app of Apps; let i = index>
<div id ="{{app[i]}}" class="row">{{app[i]}}</div>
以及按钮形式的消息列表:
<li *ngFor="let msg of messages; let i = index" id="message-{{ i }}" >
<button type="button" id =
我有以下几点:
public posts: QueryRef<PostsInterface>;
this.posts = this._postService.get(); //in ngOnInit
在相应的HTML中:
<mat-card *ngFor="let post of posts | async">
然后可以使用{post.name}}等在html中显示每个post的字段。
我的问题是,当我尝试下面的内容时,如何通过文章中的QueryRef实现相同的迭代?:
for (let post of this.posts) {
cons
希望你们能帮我。我们的计划是用.json循环显示保存在ngFor文件中的数据。
到目前为止,在我的代码中,我总是遇到以下错误:
Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
我研究并知道我必须用管道来修理它。但我不知道它是如何工作的,因为我对角度很陌生。
这就是我加载JSON并将其标记到temp变量的方式:
ngOnInit(): v