Donāt sort with a Pipe. That functionality was removed from Angular for a reason, and the Angular Pipe docs explain why. Sort in your controller, render in your HTML.
Hi ,Sorry for the inconvenience, my requirement is i need to do date filtering using predefined/custom pipes ā¦
in all the example i refer , they just doing business logic in pipe, and using that pipe at view/HTML level ,like this {{ date | āyyyy MM ddā}} ā¦etcā¦ my need is same thing how can we do in controller (ts file) under some methodā¦how i can i call that pipe ,please helpā¦
Define your sorting function, then sort your array into sortedDates or something, then in the template use *ngFor over sortedDates. I do this with Observables, so the Observable emits a new value each time the sorted array changes and this new array value gets rendered in the template.
I only think of Pipes as a mask. The data is already computed, and I want to show only two decimal places, or all capital letters, something like that. So a Pipe performs extremely simple calculation, nothing hard.
I donāt know anything about the Angular date pipe, because I use date-fns. But why do you need a special pipe for what you are doing? Why canāt you just use date:'MM-dd-yyyy' ?
My Requirement is iām getting start_time:ā20:00ā , end_time:ā11:30ā values from server response, there is some more big response ,but here it is not required ā¦ i need to show 8 am to 9pm ,if start,end_times are in different meridian ,vice versa (pm- am) , both the of them are in same case then 8 to 9 am and vice versa (pm)ā¦ so i need to check them in which meridian they are so iām trying to do.
the result of vm.matchStartTimeString will be like ===> 8 amā¦
same thing iām trying to do in native apps using ionicā¦
and i make into 4 branches (both AM,AM-PM,PM-AM,both PM) , for selected state, in switch cases iām doing bussines logicā¦so, i unable to use that pipe at HTML level, i must use that pipe at controller level onlyā¦