2
삭제 작업을 확인하기 위해 팝업을 만들려고합니다. 클릭 오버 부트 스트랩 플러그인 (타사)을 사용하여 팝업을 작성하고 지시문을 작성했습니다.확인을위한 AngularJS 지시문이 부모 범위에 액세스 할 수 없습니다.
문제는 popover 버튼에 대해 컴파일 된 html에서 부모/형제 범위에 액세스 할 수 없다는 것입니다.
이 코드가하지 않는 것은 팝업 변수의 삭제 버튼에서 반복 변수 (v)가있는 범위에서 destroy 함수를 호출하는 것입니다.
JSFiddle :
function TestCtrl($scope) {
$scope.list = {
id: [{
value: 1},
{
value: 2},
{
value: 3}]
};
$scope.destroy = function(id) {
console.log("destroy called (" + id + ")");
}
}
angular.module('TestApp', []).directive('buttonDelete', function($compile, $rootScope) {
return {
restrict: 'E',
replace: true,
template: '<a class="button-delete"><i style="margin-top: 4px;" class="icon- remove"></i></a>',
link: function(scope, element, attrs) {
// debugger;
//element.bind('click', function(e) {
// var popover = $();
// element.clickover({content: 'test'});
element.clickover({
global: true,
title: 'Are you sure?',
content: function() {
//debugger;
var element = $compile("<div class='btn-toolbar'><button id='button-confirm-delete-cancel' data-dismiss='clickover' class='btn'>Cancel</button><button id='button-confirm-delete-ok' class='btn btn-danger' ng-click='destroy(v)'>Delete</button></div>")(scope.$parent);
return element.html();
}
//});
});
}
}
});
나를 위해 일하고처럼 보이는