0
나는 요소 html을 대체 할 때 대체하기 전에 원래 코드로 돌아갈 방법을 모르겠다는 문제점이 있습니다. 내 코드는 다음과 같습니다. http://jsfiddle.net/Mahmoudbay/o166xg0s/94/ 여기 컨트롤러입니다.after element.replaceWith (contents) 어떻게 원래 코드로 돌아갈 수
angular.module('App', [])
.controller('myCtrl', function($scope) {
$scope.checked = true;
})
.directive('ngBatchIf', function($compile) {
return {
restrict: 'A',
scope: {
check: '@'
},
controller: function($scope) {},
link: {
pre: function(scope, elm, attrs) {
attrs.$observe('check', function() {
// After flattening, Angular will still have the first element
// bound to the old scope, so we create a temporary marker
// to store it
var contents = elm.contents();
if (scope.check === "true") {
console.log(scope.check);
} else {
console.log(scope.check);
elm.replaceWith(contents);
}
})
}
}
}
});
감사합니다.
나는 그것을 만들려고했지만 여전히 작동하지 않는다. – Mahmoud