<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body ng-app="myApp" ng-init="names=[
{name:'Jani',country:'Norway'},
{name:'Hege',country:'Sweden'},
{name:'Kai',country:'Denmark'}]" my-directive>
<script>
var app = angular.module("myApp", []);
app.directive("myDirective", function() {
return {
template : "<h1>Made by My directive!</h1>"
};
});
</script>
<p>Looping with objects:</p>
<ul>
<li ng-repeat="x in names">
{{ x.name + ', ' + x.country }}</li>
</ul>
</body>
</html>
You can invoke a directive by using:
Element name
Attribute
Class
Comment
-----------------------------------
This is by using Attribute
------------------------------------
Only the template content of myDirective will be displayed.
output:
*******
Made by My directive!
Element name
Attribute
Class
Comment
-----------------------------------
This is by using Attribute
------------------------------------
Only the template content of myDirective will be displayed.
output:
*******
Made by My directive!
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.