【问题标题】:get value from object in angular以角度从对象获取值
【发布时间】:2015-09-14 08:11:06
【问题描述】:

在控制器中

$scope.html = $sce.trustAsHtml('This is my html');
$scope.showpopup = function(scopVar,data){
    console.log(data);
}

在模板中:

<h2 ng-click ="showpopup('html',html)" ng-bind-html="html" ></h2>

我想要“showpopup”函数内的 html 范围的值(即:这是我的 html)。当我控制台时,它会像这样打印

 This is my html {$$unwrapTrustedValue=function(), valueOf=function(), toString=function()}

那么我怎样才能得到实际值(即这是我的 html)?

【问题讨论】:

    标签: javascript angularjs object


    【解决方案1】:
    console.log($sce.getTrustedHtml(data));
    

    文档可以在https://docs.angularjs.org/api/ng/service/$sce找到

    【讨论】:

      猜你喜欢
      • 2021-03-05
      • 2023-02-06
      • 2021-02-03
      • 2021-09-05
      • 1970-01-01
      • 1970-01-01
      • 2015-11-15
      • 2018-04-09
      • 1970-01-01
      相关资源
      最近更新 更多