i have a problem that when i replace an element html i don't know how to go back to the original code before replacement. Here is my code. http://jsfiddle.net/Mahmoudbay/o166xg0s/94/ here is the controller.
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);
}
})
}
}
}
});
thank you.