var app = angular.module(“myApp”, []);
app.controller(‘AppController’, function($scope) {
var users=[];
var user1={};
user1.firstName=”Satyam”;
user1.lastName=”Kumar”;
users.push(user1);
var user2={};
user2.firstName=”Ravi”;
user2.lastName=”Sankar”;
user2.push(user2);
$scope.users=students;
});
app.directive(‘user’, function() {
//define the directive object
var directive = {};
//restrict = E, implies that directive is Element directive
directive.restrict = ‘E’;
//element will be replaced by this text/html
directive.template = “First Name: {{user.firstName}} , Last Name: {{user.lastName}}”;
var linkFunction = function($scope, element, attributes) {
element.css(“background-color”, “#e1e1e1”);
}
directive.link=linkFunction;
return directive;
});

Leave a Reply

Your email address will not be published. Required fields are marked *