1

I have a element that prints a message. That message contains dynamic values. So, how can i evaluate what's inside the message before it gets evaluated inside the tag?

$scope.name = 'John' $scope.message = 'Hello {{name}}'

<li>{{message}}<li>

0

2 Answers 2

3

You can use the $interpolate service to evaluate that expression.

.controller('DemoController', function($scope, $interpolate) {
   $scope.name = 'John';
   $scope.message = $interpolate('Hello {{name}}')($scope);
});
Sign up to request clarification or add additional context in comments.

Comments

1

ryeballar is right. or you can do it like this:

$scope.name = 'John'
$scope.message = 'Hello'+ $scope.name;

<li>{{message}}<li>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.