Javascript 角度:Dom添加了ng单击返回错误

Javascript 角度:Dom添加了ng单击返回错误,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,我有两个职能: $scope.modif = function (e) { $scope.temp = e.target.offsetParent .offsetParent .childNodes[3] .childNodes[(this.$index+1)*2]; $($scope.

我有两个职能:

$scope.modif = function (e) {
        $scope.temp = e.target.offsetParent
                              .offsetParent
                              .childNodes[3]
                              .childNodes[(this.$index+1)*2];
        $($scope.temp.childNodes[11])
         .html($compile('<button ng-click="save($event)">Save</button>')($scope));
};
这是一个全局ng repeat this,而不是在特定的ng repeat元素中。 但是,“保存”按钮位于“修改”按钮的旁边


有人知道为什么吗

错误是将$scope放入$compile范围。 我参考这像新的范围,它的工作很好

$($scope.temp.childNodes[11]).html($compile('<button ng-click="save($event)">Save</button>')(this));
$($scope.temp.childNodes[11]).html($compile('Save')(this));
$($scope.temp.childNodes[11]).html($compile('<button ng-click="save($event)">Save</button>')(this));