微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

角度异步管道错误:'any[] 类型的参数 | null' 不可分配给类型为 'any[]' 的参数

如何解决角度异步管道错误:'any[] 类型的参数 | null' 不可分配给类型为 'any[]' 的参数

我在 *ngFor 中的 Angular 中使用管道异步时遇到了这个问题。这是我的代码

#include<bits/stdc++.h>
#define vi vector<int>
#define ui unordered_set<int>
#define all(v) v.begin(),v.end()
#define lower(s) transform(all(s),s.begin(),::tolower)
#define upper(s) transform(all(s),::toupper)
#define sortv(v) sort(all(v))
#define rev(v) reverse(all(v))
#define f first
#define s second
#define int long long int
#define float double 
#define endl "\n"
#define null NULL
using namespace std;
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " ";_print(x); cerr<<endl;
#else
#define debug(x)
#endif

void _print(int a){cerr<<a;}
void _print(float a){cerr<<a;}
void _print(char a){cerr<<a;}
void _print(bool a){cerr<<a;}
void _print(string a){cerr<<a;}

template<class T> void  _print(set<T> s1){cerr<<"[ ";for(T i:s1){_print(i);cerr<<" ";}cerr<<"]";}
template<class T> void  _print(vector<T> v1){cerr<<"[ ";for(T i:v1){_print(i);cerr<<" ";}cerr<<"]";}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("Error.txt","w",stderr);
#endif



    return 0;
}

我收到错误

<ul>
    <li *ngFor="let user of users | async | search:(filterValue | async)!">{{ user.name }}</li>
</ul>

我可以使用“!”修复搜索管道内的最后一个异步因为我知道它永远不会为空,但我无法对第一个管道做同样的事情,我知道它也永远不会为空,我怎么能使用“!”也有吗?

我已经尝试过将所有内容都放在括号中并输入“!”在它上面,但它停止识别用户用户属性

解决方法

你试过这个吗?我认为这应该有效。

<li *ngFor="let user of (users | async)! | search:(filterValue | async)!">

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。