【问题标题】:Angular ng-bind-html and ng-mouseover don't work (don't appears in code)Angular ng-bind-html 和 ng-mouseover 不起作用(不会出现在代码中)
【发布时间】:2017-08-09 08:53:51
【问题描述】:

我尝试使用 ng-bind-html 添加一些代码,并包含 ng-mouseover。但是ng-mouseover 部分没有出现(不起作用)在代码中

来自 angular plunker 的示例并添加我的一段代码:

ng-mouseover="test($event)"

(function(angular) {
  'use strict';
angular.module('bindHtmlExample', ['ngSanitize'])
  .controller('ExampleController', ['$scope', function($scope) {
    $scope.myHTML =
       'I am an <code>HTML</code>string with ' +
       '<a ng-mouseover="test($event)" href="#">links!</a> and other <em>stuff</em>';

    $scope.test = function(event) {
      console.log(event);
    }

  }]);
})(window.angular);

https://plnkr.co/edit/gp3Z50TJqvEfOFGrpYCT?p=preview

$scope.test() 函数从未被触发。鼠标悬停在这个小链接上方没有出现任何事件。

有什么提示吗?

【问题讨论】:

    标签: angularjs ng-bind-html


    【解决方案1】:

    您需要编写自定义指令来评估范围内的 html。

    【讨论】:

    • 有任何链接或示例吗?
    猜你喜欢
    • 1970-01-01
    • 2013-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-11
    • 2015-09-04
    • 2014-02-17
    • 2015-02-24
    相关资源
    最近更新 更多