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) } } });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.