【问题标题】:how can i use ng-click in ng-bind-html我如何在 ng-bind-html 中使用 ng-click
【发布时间】:2014-11-12 09:11:18
【问题描述】:

我在我的控制器中使用 ng-bind-html,比如

$scope.message='  You  currently have no ORDERS <a href= "javascript:void(0)" ng-click="Back()">Back13</a>';

在html页面中

<strong ng-bind-html="message">Warning!</strong>

但即使我尝试将 $compile 设置为 similar question ,Back() 也无法正常工作。 谁能解决这个问题?

【问题讨论】:

    标签: javascript html angularjs ng-bind-html


    【解决方案1】:

    试试这个

    $scope.message='  You  currently have no ORDERS <a **href="javascript:;"** ng-click="Back()">Back13</a>';
    

    href="javascript:void(0)" 更改为href="javascript:;"

    也可以看看下面的讨论

    ng-click do not work when a template bound using ng-bind-html-unsafe

    AngularJS: ng-bind-html doesn't work with button tag

    【讨论】:

    • 感谢@user256103 的回复,但您的建议对我不起作用,刚才我已经更新了plunker 中的代码,如果可能的话,请更改plnkr 来解决问题。
    猜你喜欢
    • 2014-07-16
    • 2014-02-17
    • 2016-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-27
    • 2015-06-14
    相关资源
    最近更新 更多