我找不到运行这东西的方法..。我使用ng-bind-html从db加载文本。我想将变量添加到几种语言的中的一种。但是我不明白正确的语法。我想使用这样的东西:
<div ng-bind-html="detail.txt+lang"></div>其中lang是一个rootScope变量("_en“、"_it”等等),谢谢
发布于 2016-01-25 19:54:27
我会这样做:
//inside the controller for the view
$scope.writeValueFromDb = function() {
//here you can access the $rootScope
//(after including it as a dependency in the controller)
//and from the $rootScope object you can access the language variable
}这样,您就不必在视图中绑定的每个方法中手动从$rootScope传递语言变量。
在视图中,您可以正常绑定它:
<div ng-bind-html="writeValueFromDb()"></div>https://stackoverflow.com/questions/34991487
复制相似问题