Why this custom directive in angular js not working for me.I am only getting the user: but not getting the names of the user which I passed in the userinfo custom directive tag
user_directive_index.html file:
<html ng-app='app' >
<head>
</head>
<title>
User Directive
</title>
<body >
<div>
<div ng-model='firstcontroller'>
<userinfo user="Raj"></userinfo>
</br>
<userinfo user="Sudhir"></userinfo>
</div>
</div>
<script type="text/javascript" src="../js/angular.min.js"></script>
<script src='app.js'></script>
</body>
</html>
App.js file:
var app1=angular.module('app',[]);
app1.controller('firstcontroller',function($scope){
$scope.Raj={};
$scope.Raj.firstname='Rajeshwar';
$scope.Raj.lastname='Bose';
$scope.Sudhir={};
$scope.Sudhir.firstname='Sudhir';
$scope.Sudhir.lastname='Ranjan';
});
app1.directive('userinfo',function(){
var directive={};
directive.restrict='E';
directive.template='User:{{user.firstname}} {{user.lastname}}';
directive.scope={
user:"= user"
};
return directive;
});
I got this code from: http://tutorials.jenkov.com/angularjs/custom-directives.html
