【发布时间】:2019-07-04 06:01:45
【问题描述】:
我正在发布类似于 Facebook 帖子的帖子,当我在帖子中发布数据时,当我输入“@”搜索返回用户名的数据时,如果我先输入“#”来调用 API 并返回可用的标签离子 4.
我做了什么:
page.html
<ion-item>
<ion-textarea rows="3" (ionInput)="searchPeople($event)" cols="20" formControlName="comment"
placeholder="Tweet your reply" spellcheck="true" autoComplete="true" autocorrect="true" autofocus required>
</ion-textarea>
</ion-item>
page.ts
searchPeople(ev: any) {
// set val to the value of the searchbar
let val = ev.target.value;
let firstchar = val.charAt(0);
if (firstchar = "@") {
console.log("search people");
}
else if (firstchar = "#") {
console.log("hash tag");
} else {
console.log("error");
}
}
我确实喜欢这个,但它不起作用......
【问题讨论】:
-
你应该比较不分配更改 firstchar = "@" firstchar == "@"
标签: angular ionic-framework ionic4