仍然不是一个完美的解决方案!!!-只是为了说明如何进行动态编译
app.controller('AppController', function ($scope, $compile) { var $el = $('<td contenteditable><input type="text" value=""/></td>' + '<td contenteditable><input type="text" value=""/></td>' + '<td>' + '<span>' + '<button id="createHost" data-ng-click="create()"><b>Create</b></button>' + '</span>' + '</td>').appendTo('#newTransaction'); $compile($el)($scope); $scope.create = function(){ console.log('clicked') }})不要将控制器用于dom操作-必须在指令的帮助下完成



