Sergio
Sergio

Reputation: 203

AngularJs - Combine on ng-bind : literal (i18n) + $scope element

I've been trying to combine labels with elements of $scope without success. Any idea if that's possible and how?

What I've tried:

principalpage.user = 'User'
$scope.user= 'Jim'

ng-bind="'principalpage.user' | translate {{user}}"
ng-bind="{{'principalpage.user' | translate}} {{user}}"
ng-bind="'principalpage.user' | translate user"
ng-bind="'principalpage.user' | translate 'user'"

They work good separately but not together.

PD: Used ng-bind instead of {{...}} for the best practices of 'AngularJS' and because the {{..}} showed up when the page is refreshing.

Upvotes: 0

Views: 350

Answers (1)

Cerbrus
Cerbrus

Reputation: 72947

From what I can see, this should do the trick:

ng-bind="('principalpage.user' | translate) + ' ' + user"

Translate 'principalpage.user', then add the user variable behind it.

Upvotes: 3

Related Questions