I am facing a problem while I am using Angular mention library.
Here is my typescript code.
items: Object[] = ["jay","roy","gini","rock","joy","kiya"];
I am using this defined named items array in my component.html file
<input type="text" id="cname" name="cname" placeholder="Type Here.." [mention]="items">
so it is creating a text box and it is giving suggestion when I am typing any user name.
Suppose I type @j then it will suggest all the names starting with the name j and after entering it will be entered into the text box with the sign @. So basically it is giving the functionality of the auto search from the array and for this, I have imported the mention library into my Angular7 application.
I am designing a project in which all the users are coming from the web service. So I need to store those users into that items named array.
The JSON format is as follows.
[
{
"attributes": {
"User": "jay"
}
},
{
"attributes": {
"User": "roy"
}
},
{
"attributes":{
"User": "kiya"
}
},
{
"attributes":{
"User": "gini"
}
},
{
"attributes": {
"User": "rock"
}
},
{
"attributes": {
"User": "joy"
}
}
]
The above JSON data is coming from a web server and I am storing it into a variable. So I want to store this into that above array named items so that in my text box while typing it can give autosuggest with the real data.
I have tried this thing but at the time of typing in the text box, it is not giving any suggestions.
itemsas aObject[]which means an array of objects. You then initialize this variable to the value["jay","roy","gini","rock","joy","kiya"];which is an array of strings (string[]). That doesn't make sense