【发布时间】:2021-08-03 03:29:29
【问题描述】:
我想隐藏相应行的付款到期日单元格为空的行。 虽然 Payment Due Date 的任何值为 null 或为空,但我想分别隐藏整行。
user.service.ts
import { Injectable } from '@angular/core';
import { HttpClient} from '@angular/common/http'
@Injectable({
providedIn: 'root'
})
export class UsersService {
constructor( private http:HttpClient) { }
getData(){
let url="https://Test.azurewebsites.net/api/accounts/getall";
return this.http.get(url);
}
}
app.component.ts
import { analyzeAndValidateNgModules } from '@angular/compiler';
import { Component } from '@angular/core';
import { UsersService} from './users.service'
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'coding-test';
data : any
constructor( private user:UsersService){
this.user.getData().subscribe(data=>{
console.warn(data)
this.data = data
})
}
}
app.component.html
<div class="jumbotron jumbotron-fluid">
<div class="container">
<h1 class="display-6">Display Sorted Account Info</h1>
<table class="table table-striped" >
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
<th >Amount Due</th>
<th>Payment Due Date</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of data" >
<td>{{item.LastName}},{{item.FirstName}}</td>
<td>{{item.Email}}</td>
<td>{{item.PhoneNumber | phone}}</td>
<td>{{item.AmountDue | currency}}</td>
<td>{{item.PaymentDueDate | date}}</td>
</tr>
</tbody>
</table>
</div>
</div>
【问题讨论】:
标签: html css angular pipe httpclient