I get the data form backend in miliseconds need to bind in hh:mm and when i bind it get a number a try a pipe for converting but didn't help
Maximum Outage Time (per Month): {{objSevrvice.MaximumOutageTimePerMonth | miliSeconds}}
I get the data form backend in miliseconds need to bind in hh:mm and when i bind it get a number a try a pipe for converting but didn't help
Maximum Outage Time (per Month): {{objSevrvice.MaximumOutageTimePerMonth | miliSeconds}}
You can create a pipe to use throughout your html to transform string dates, milliseconds, or any valid time parameter into a date like this:
@Pipe({name: 'toDate'})
export class ToDatePipe implements PipeTransform {
transform(value: number | string) {
// Convert the value to a date, if the date is invalid,
// then we return the current date/time.
return new Date(value) || new Date()
}
}
Next you can then use the pipe alongside Angular's date pipe in your html like this:
@Component({
selector: 'my-component',
template: `
<span>{{myVale|toDate|date:'hh:mm:ss'}}</span>
`
})
export class MyComponent implements OnInit {
myValue = 0
constructor(private myService: MyService){ }
ngOnInit() {
this.myService.getValue().subscribe(v => {
this.myValue = v
})
}
}