Directive to replace itself
Description
The following code shows how to use Directive to replace itself.
Example
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<style type='text/css'>
row {<!--from ww w . j a va 2s .c om-->
color: red;
}
</style>
<script type='text/javascript'>
angular.module('myApp',[])
.directive('row', function($compile) {
return {
restrict: 'E',
link: function(scope, element, attrs) {
element.html('<div>I should not be red</div>');
$compile(element.contents())(scope);
}
}
});
</script>
</head>
<body ng-app="myApp">
<row>***</row>
</body>
</html>