I need to get the Element ID from AngularJs.
I have tried this but it didn't work.
angular.module('AngStarter').directive('oblInLineEditor', function() {
return function(scope, element, attr) {
console.log("value = " + scope.$eval(attr.id));
}
});
you don't need scope.eval here.
angular.module('AngStarter').directive('oblInLineEditor', function() {
return function(scope, element, attr) {
console.log("value = " + attr.id);
}
});
see this example: http://jsfiddle.net/kevalbhatt18/bu6jxzan/
var myApp = angular.module('AngStarter', []);
myApp.directive("oblInLineEditor", function(){
return {
restrict: "E",
link: function(scope, elem, attrs) {
console.log(elem[0].id);
console.log(attrs.id)
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With