angularjs - Getting Attribute value in ng-repeat from a Directive -
well have ng repeat :
<div ng-repeat="x in xs" ><a id="x.id" my-directive>blabla {{x.number}}</a></div> and have directive :
module.directive('mydirective', ['$document', function ($document) { return { replace : true, link: function (scope, element, attr) { element.on('mousedown', function (event) { // prevent default dragging of selected content event.preventdefault(); startx = event.pagex - x; starty = event.pagey - y; $document.on('mouseup', mouseup); }); function mouseup() { $document.off('mouseup', mouseup); console.log(attr.id); scope.deletealert(1); //function delete element scope table } } }; }]); and can't value of "id" , it's returning "x.id" !!
so how can value of attribute ?
i want id pass argument function delete div in question. now, i'm passing "1" function , deleting first element of list.
can me figure out please!!
update
here fiddle test
since you're using in id, wrap in {{ in contents:
<div id="{{fire.id}}" my-directive>
Comments
Post a Comment