Add more text after using a filter in ng-bind in angularjs

AngularjsNg BindAngular Filters

Angularjs Problem Overview


So I want to put a variable through a filter inthe ng-bind directive

ng-bind="input | filter"

but I want to insert more text

ng-bind="input | filter + 'more' "

but this isn't working. Is there a way to add more text in ng-bind, like you could if you were simply using {{}}:

{{input | filter}} more

Angularjs Solutions


Solution 1 - Angularjs

Instead of interpolating(using {{}}) something in the ng-bind directive you can simply enclose the filtered value with a parenthesis and append your text.

<h1 ng-bind="(input | filter) + ' more stuff'"></h1>

furthermore, if the text you want to add is not in any way dynamic then I suggest you append another element to bind the filtered value and then add the text after that element.

e.g.

<h1><span ng-bind="(input | filter)"></span> more stuff</h1>

This saves you one concatenation process.

Example here

Solution 2 - Angularjs

You can do something like this:

<h1 ng-bind="'{{input | filter}}' + ' more stuff'"></h1>

Here's an example: http://plnkr.co/edit/rEva7FTPFtr3im7RUlQk?p=preview

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionlaggingreflexView Question on Stackoverflow
Solution 1 - AngularjsryeballarView Answer on Stackoverflow
Solution 2 - AngularjsdustyrockpyleView Answer on Stackoverflow