小编use*_*er1的帖子

编译ng-bind-html后,ng-click无法正常工作

我有一个指令

app.directive("dir", function($compile, $sce){
      return{
        restrict: "E",
        link: function(scope, element, attr){
          scope.$watch('content',function(){
            var html = $sce.trustAsHtml(attr.content);
            scope.alabala = $compile(html)(scope);
          },true);
        },
        template: "<div ng-bind-html='alabala'></div>",
      }
    });
Run Code Online (Sandbox Code Playgroud)

控制器:

function MainController($scope, $http, customService, $location, $sce, $compile){
    $scope.init = function(){
        customService.get().success(function(data) {
                 var html = $sce.trustAsHtml(data);
                $("#dir").attr("content", data);

            });
    };
}
Run Code Online (Sandbox Code Playgroud)

在我的索引页面上我有:

<div id="div" ng-controller="MainController" class="pull-right span3" ng-init="init()">
      <dir id="dir" ></dir>
</div>
Run Code Online (Sandbox Code Playgroud)

每次包含不同的html时,我的自定义服务都会返回

<button ng-click='click()'>Click me</button>
Run Code Online (Sandbox Code Playgroud)

我想要做的是每当我在我的指令的内容中推送一个不同的值来编译它并将它放在我的html中并从我的控制器处理click函数时.因为我是AngularJS的新手,所以我一直在努力解决这个问题.请帮忙.

html javascript jquery angularjs angularjs-directive

11
推荐指数
1
解决办法
2万
查看次数

没有调用Woocommerce订单删除钩子回调

我正在尝试将一个函数挂钩到订单删除(当从管理页面点击永久删除时),但由于某种原因,该函数未被调用.我的代码看起来像

add_action('woocommerce_before_delete_order_item', function($id) {
    $order = new WC_Order($id);
    //do some stuff with order meta data
}, 10, 1);
Run Code Online (Sandbox Code Playgroud)

我试图在函数内抛出异常,但没有发生错误.有人可以帮忙吗?

php wordpress hook wordpress-plugin woocommerce

1
推荐指数
1
解决办法
1700
查看次数