I'm trying to create a directive in angularJS. But it's not working. What I have done is as follow.
my main html code
<body ng-app="birthdayToDo" ng-controller="main">
<h1>Hello Plunker!</h1>
<myCustomer></myCustomer>
</body>
My Js code :
var app = angular.module('birthdayToDo', []);
app.controller('main', function($scope) {
$scope.employees=[
{
Name:"Amit",
Email:"[email protected]"
},
{
Name:"Ajay",
Email:"[email protected]"
},
{
Name:"Rahul",
Email:"[email protected]"
},
{
Name:"Aakash",
Email:"[email protected]"
},
{
Name:"Rohit",
Email:"[email protected]"
},
];
});
app.directive('myCustomer', function() {
var directive = {};
directive.restrict = 'E'; /* restrict this directive to elements */
directive.templateUrl = "directiveFile.html";
return directive;
});
my directiveFile.html code
<table>
<tr>
<td>SNo.</td>
<td>Name</td>
<td>Email</td>
</tr>
<tr ng-repeat="employee in employees">
<td>{{$index+1}}</td>
<td>{{employee.Name}}</td>
<td>{{employee.Email}}</td>
</tr>
</table>
But this code is not working . What's wrong I'm doing.