I have one array in angular and one form in which I want to replace placeholder's value from that array.
check below code :
fieldType = [{
id: 1,
defaultData: {
inputPlacehoolder: 'enter Text'
}
},{
id: 2,
defaultData: {
inputPlacehoolder: 'enter Email'
}
},{
id: 3,
defaultData: {
inputPlacehoolder: 'enter Value'
}
}]
fieldArray = [
{
type: 1,
value: "demo"
},
{
type: 2,
value: "[email protected]"
}
]
and Here is html code :
<form *ngFor="let field of fieldArray">
<input type="text" placeholder="{{ fieldType | filterPipe: field.type : 'inputPlacehoolder' }}" />
</form>
and here is my pipe like this :
transformPipe(fieldType, id, key) {
return fieldType.find(item => item.id == id).defaultData[key]
}
expected output should like this :
<input type="text" placeholder="enter Text" />
<input type="text" placeholder="enter Email" />
I want to filter array and show only one string in html using angular pipe. but this pipe return me error like : Multiple components match node with tagname
can anyone please suggest me how to filter array and show only single string in angular ?
I can't call function in that placeholder binding because it causes performance issues not even merge that two array for show direct value using loop.
Pipe is the only way. please help me to figure it out...