I am working on a team planner manager where the user can create a tile(=task) when clicking on the body and dragging it around the canvas. I am trying to link the created task to the correct user. On the left of the screen I have a list of users. Now the task are just placed random on the grid. The grids logic is made up of rows and columns. So I thought I first determine the y postion of each user and then link the position on the task to the user.
I am working with Angular and Node to create this team planner
Via a custom directive i obtained the user position (part of the code of my app.js file):
$rootScope = {};
$rootScope.users = [];
contentEditor.directive('custom', function($document) {
return {
restrict: 'E',
scope: true,
link: function(scope, element, attrs) {
var mail = $(element[0]).attr('data-email');
console.log("mail ", $(element).attr('data-email'));
$rootScope.users.push({"top ":element[0].offsetTop, });
console.log(scope)
console.log("Y positon of a user circle " + element[0].offsetTop);
}
}
});
Part of the html code:
<!-- START SIDEBAR -->
<div id="sidebar" class="md-whiteframe-z4">
<img id="logo" src="images/logo.png" alt="" >
<div class="userList">
<ul>
<li ng-repeat="user in userInfo" id="userPos" class="circular" data-email="{{user.email}}"><p class="initials"><custom></custom>{{user.initials}}</p></li>
</ul>
</div>
</div>
<!-- END SIDEBAR -->
To get a better idea of my app check out this link -> http://gyazo.com/2e011b0e38bc1e36c198bbaa322ad06c
My question is how to access the data email from my data attribute (see list item). Now it returns undefined when I try to access it.
$(element[0]).data('email')
? – alisabzevari Jul 16 '15 at 8:28scope: { dataEmail: '=' },
then you could access it in your directive by$scope.dataEmail
(though I would just call it email) – Amicable Jul 16 '15 at 8:34