I think better to use custom pipe rather than keeping your login in html. it may cause the issue. Broader way is to create custom pipe and keep your logic into separate file. Here how you can create your custom pipe.
Pipe:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'timepart'
})
export class TimePartPipe implements PipeTransform {
transform(value: any, part: string, symbol: string): string {
if (symbol == "" || symbol == null) {
symbol = ":";
}
var i = value.split(symbol);
if (part == "hh")
return i[0];
if (part == "mm")
return i[1];
if (part == "ss")
return i[2];
}
}
HTML:
// pass symbol and part which you want as argument
<input matInput placeholder="Hours" matInput [value]="customer?.timeArray[0]" >
</mat-form-field> -->
<mat-form-field class="timings-hrs">
<input matInput placeholder="Minutes" matInput [value]="customer?.time | timepart : 'mm'" >
</mat-form-field>
<mat-form-field class="timings-min">
<input matInput placeholder="Seconds" matInput [value]="customer?.time | timepart : 'ss'" >
This is more proper way to manipulate your HTML output.
DEMO : https://stackblitz.com/edit/angular-movie-read-load-json-sample-eg-pvnwaf?file=src%2Fapp%2Flist%2Flist.component.html