angularjs - After element.replaceWith(contents) how can go back to the original code -
i have problem when replace element html don't know how go original code before replacement. here code. http://jsfiddle.net/mahmoudbay/o166xg0s/94/ here 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 still have first element // bound old scope, create temporary marker // store var contents = elm.contents(); if (scope.check === "true") { console.log(scope.check); } else { console.log(scope.check); elm.replacewith(contents); } }) } } } });
thank you.
maybe can create clone of original element?
var originalelm = elm.clone()
Comments
Post a Comment