Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

append a string to the beginning of ng-model

I need to append a string to the ng-model variable. I'm using the ng-model for filtering. All my elements that i'm searching are starting with the string "template". I want to add it to the ng-model for not entering "template" in my search input. I'm using the ng-model for another filtering.

Here is my code:

<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">

I want to insert the string "template" at the beginning of the 'searchText.template' value.

(like this: "template"+searchText.template)

like image 783
Guy Ben-Shahar Avatar asked Nov 30 '25 00:11

Guy Ben-Shahar


1 Answers

You should be able to add 'tempate' to the beginning of your filter like this:

<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)">
like image 182
vlin Avatar answered Dec 02 '25 15:12

vlin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!