我有这个模型:
<ArrayOfContactList xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/test.Controllers">
<ContactList>
<Acquisition>2019-01-01T00:00:00</Acquisition>
<AddModCode>00000</AddModCode>
<Address/>
<AssistanceDeadline>2019-01-01T00:00:00</AssistanceDeadline>
<City i:nil="true"/>
<ContactID>134</ContactID>
<ContactStateID>2</ContactStateID>
<ContactTypeID>1</ContactTypeID>
<License>000000</License>
<NCalls>1</NCalls>
<Name>Test Name</Name>
<Note>NOTE</Note>
<PIva>xxxxxxxx</PIva>
<ProductDesc>Product Desc</ProductDesc>
<ProductID>1</ProductID>
<Referents xmlns:d3p1="http://schemas.datacontract.org/2004/07/test.Models">
<d3p1:Referent>
<d3p1:Contact i:nil="true"/>
<d3p1:ContactID>134</d3p1:ContactID>
<d3p1:Email>email@email.it</d3p1:Email>
<d3p1:LastName>LAST NAME</d3p1:LastName>
<d3p1:Name>NAME</d3p1:Name>
<d3p1:Note>NOTE</d3p1:Note>
<d3p1:Phone>PHONE</d3p1:Phone>
<d3p1:ReferentID>19</d3p1:ReferentID>
<d3p1:Title i:nil="true"/>
</d3p1:Referent>
</Referents>
<StateDesc>STATE DESC</StateDesc>
<TypeDesc>TYPE DESC</TypeDesc>
<Warning i:nil="true"/>
<WebApplication>WEB APPLICATION</WebApplication>
</ContactList>
我想通过搜索ContactList属性以及其中包含的Referents数组中包含的属性来过滤ContactList数组中的内容。
我有这个:
this.contactService.getAll().subscribe(contacts => {
this.allContacts = contacts;
this.assignCopy();
});
assignCopy(){
this.filteredContacts = Object.assign([], this.allContacts);
}
this.filteredContacts = Object.assign([], this.allContacts).filter( item => {
(item.Name.toLowerCase().indexOf(value.toLowerCase()) > -1) ||
(item.License.toLowerCase().indexOf(value.toLowerCase()) > -1) ||
(item.PIva.toLowerCase().indexOf(value.toLowerCase()) > -1) ||
(item.Referents.some(i => {
(i.Name.toLowerCase().indexOf(value.toLowerCase()) > -1) ||
(i.LastName.toLowerCase().indexOf(value.toLowerCase()) > -1)
}))
})
我的问题是,即使它应用了有效的过滤器,this.filteredContacts始终为空。 你能帮助我了解我在做什么错吗?