<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body ng-app="myApp">
<w3-test-directive></w3-test-directive>
<div w3-test-directive></div>
<script>
var app = angular.module("myApp", []);
app.directive("w3TestDirective", function() {
return {
restrict : "A",
template : "<h1>Made by a directive!</h1>"
};
});
</script>
<p><strong>Note:</strong> By setting the <strong>restrict</strong> property to "A", only the HTML element with the "w3-test-directive" attribute has invoked the directive.</p>
</body>
</html>
// Code goes here
/* Styles go here */
<div>
w3s108-AngularJS Directives Custom
<br/>
code example:
<hr>
index.html
<br/>
<textarea
id='codeoutput'
style="width: 100%;height: 300px;background-color: #dffff4;
font-size: 1em;font-family: Verdana, Arial, Helvetica, sans-serif;
border: 1px solid black;">
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body ng-app="myApp">
<w3-test-directive></w3-test-directive>
<div w3-test-directive></div>
<script>
var app = angular.module("myApp", []);
app.directive("w3TestDirective", function() {
return {
restrict : "A",
template : "<h1>Made by a directive!</h1>"
};
});
</script>
<p><strong>Note:</strong> By setting the <strong>restrict</strong> property to "A", only the HTML element with the "w3-test-directive" attribute has invoked the directive.</p>
</body>
</html>
</textarea>
<hr/>
<iframe
allowfullscren="allowfullscren"
frameborder="0"
src="https://embed.plnkr.co/tZCB4RJNpmXbihQjulxB?show=preview"
style="height: 400px; width: 100%;">
</iframe>
<hr>
https://www.w3schools.com/angular/angular_directives.asp
<hr>
201603
</div>