I'm just a beginner in angular JS. I'm learning to a write a directive.
<!DOCTYPE>
<html ng-app="myapp">
<head>
<script src="angular.min.js"/>
<script>
var app = angular.module('myapp', []);
app.directive('helloWorld',function()
{
return{
restrict: 'AEC',
replace: 'true',
template: '<h1>helloWorld</h1>'
}
});
</script>
</head>
<body>
<h1>Hello World example</h1>
<hello-world></hello-world>
</body>
</html>
Now, what is wrong in the above code, I get an error - Uncaught Error: [$injector:modulerr].
1. Is controller mandatory to write a directive, does it not inherit from $rootscope.
2. How can I master directives.