#Error w/ sorting pipe

1 messages · Page 1 of 1 (latest)

hearty vale
#

Hi please share your pipe code here directly, not as a screenshot

#

g!codeblock @slate oasis

wooden fogBOT
#

Hi @slate oasis, you can use the following snippet to have your code formatted and syntax highlighted by Discord. Replace ts with the language you need (i.e. html, js, css, etc).

```ts
// your code goes here
```

hearty vale
#

value parameter type needs to be fixed. The value is your array of posts. You must use the same type

slim river
#

Still the same problem: your pipe only accepts an array o Post, but you're passing something which can be an array or posts or which can be null. Either check for null before invoking the pipe, or accept null as argument in your pipe and deal with the null case.

slim river
#

That, or with an ngIf (to only display the sorted posts if you have an array of posts)

hearty vale
#

For the same reason as your initial issue: on template side, you are passing an array of string

#

That's not one key

#

The second parameter is the value of your 'sort' on template side

#

sort:['subject', 'desc'] is soetField: key of T

#

But types don't match

#

That's an array here, not a key

#

You can't do a[sortfield] while passing an array to sortField

hearty vale
#

On template side, each parameter is separated with :. Here you are still passing an array as the first parameter.
sort:undefined:'desc'