如何在另一个表达式中评估angularjs表达式 [英] How to evaluate angularjs expression inside another expression
本文介绍了如何在另一个表达式中评估angularjs表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个打印消息的元素.该消息包含动态值.那么,如何在标记内对其进行评估之前,先评估该消息内的内容?
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 ='约翰'$ scope.message ='你好{{name}}'
<代码>< li> {{message}}< li>
推荐答案
您可以使用 $ interpolate
服务评估该表达式.
You can use the $interpolate
service to evaluate that expression.
.controller('DemoController', function($scope, $interpolate) {
$scope.name = 'John';
$scope.message = $interpolate('Hello {{name}}')($scope);
});
这篇关于如何在另一个表达式中评估angularjs表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文