bind multiple values using ng-bind

Chad Watkins picture Chad Watkins · Jun 23, 2015 · Viewed 24.1k times · Source

Can I bind multiple values using ng-bind like so :

<p ng-bind="instructor.first_name instructor.last_name"></p>

Whenever I try this I get the following error:

Error: $parse:syntax Syntax Error

I know I can do the same using the curly braces

<p>{{instructor.first_name}}{{instructor.last_name}}</p>

but I would like to avoid this if I can since the rest of the code base uses ng-bind and I would to stay consistent. Thanks.

Answer

Maksym Kosak picture Maksym Kosak · Nov 24, 2015

You can use "+" for concatenation of the expressions. The following should work for you: <p ng-bind="(instructor.first_name) + (instructor.last_name)"></p>. You can even add filters there <p ng-bind="(instructor.first_name | filterName) + (instructor.last_name)"></p>.