Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs ng在动态内容的内部单击不起作用_Angularjs - Fatal编程技术网

Angularjs ng在动态内容的内部单击不起作用

Angularjs ng在动态内容的内部单击不起作用,angularjs,Angularjs,我从外部服务获取html内容。我使用angular js提取内容并显示在我的网站上。这些内容有内部链接,这是从服务中提取更多数据所必需的。所以我需要像这样的东西 我可以从后端处理数据。但我得到的错误是 Uncaught ReferenceError: myfunctionis not defined. 这是我在服务器请求后显示动态内容的方式 <p ng-bind-html="getSafeHtml(responseDisplayArticle.body)" class="text-j

我从外部服务获取html内容。我使用angular js提取内容并显示在我的网站上。这些内容有内部链接,这是从服务中提取更多数据所必需的。所以我需要像这样的东西

我可以从后端处理数据。但我得到的错误是

Uncaught ReferenceError: myfunctionis not defined.
这是我在服务器请求后显示动态内容的方式

 <p ng-bind-html="getSafeHtml(responseDisplayArticle.body)" class="text-justify"></p>

  $scope.getSafeHtml = function(x)
  {
     //return $sce.trustAsHtml(x);
      var decoded = angular.element('<p>').html(x).text();
      return $sce.trustAsHtml(decoded);
  };

$scope.getSafeHtml=函数(x) { //返回$sce.trustAsHtml(x); var decoded=angular.element(“”).html(x.text(); 返回$sce.trustAsHtml(已解码); };
ResponseDisplayaArticle.body包含html内容,其中包含ng click。
如何使其工作。

在控制器代码中,需要将函数公开给作用域

var app = angular.module('myapp');
app.controller('SomeController', ['$scope', function($scope) {
  function myfunction(arg1, arg2) {
    // ...
  }
  $scope.myfunction = myfunction;
}]);

代码在哪里?问题不太清楚,无法回答。好吧,我编辑了你的帖子以揭示代码,但我仍然不确定你在问什么。很可能,angular JS已经编译了,这就是为什么ng click不是注册事件的原因。使用apply()。需要更多代码。请查看代码更新。如果我的答案错误,请更正我。但是为什么有人不阅读答案,而只是在答案发布1分钟后点击“-1”?