我需要向ng模型变量追加一个字符串。
我用ng模型过滤。我搜索的所有元素都以字符串“template”开头。
我想把它添加到ng模型中,因为我的搜索输入中没有输入“template”。
我正在使用ng模型进行另一个筛选。
这是我的代码:

<label>Search By Station: <input ng-model="searchText.screensId"></label>
<label>Search By Template: <input ng-model="searchText.template"></label>
<div data-ng-repeat="msg in messages | filter:searchText">

我想在'searchText.template'值的开头插入字符串“template”。
(就像这样:“template”+searchText.template)

最佳答案

您应该能够将“tempate”添加到筛选器的开头,如下所示:

<label>Search By Station: <input ng-model="searchText.screensId"></label>
<label>Search By Template: <input ng-model="searchText.template"></label>
<div data-ng-repeat="msg in messages | filter:('template'+searchText.template)">

关于html - 在ng-model的开头附加一个字符串,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35443496/

10-11 23:53
查看更多