我需要从AngularJs中获取元素ID。
我尝试过这个方法,但它没有起作用。
angular.module('AngStarter').directive('oblInLineEditor', function() {
return function(scope, element, attr) {
console.log("value = " + scope.$eval(attr.id));
}
});
我需要从AngularJs中获取元素ID。
我尝试过这个方法,但它没有起作用。
angular.module('AngStarter').directive('oblInLineEditor', function() {
return function(scope, element, attr) {
console.log("value = " + scope.$eval(attr.id));
}
});
这里不需要使用 scope.eval。
angular.module('AngStarter').directive('oblInLineEditor', function() {
return function(scope, element, attr) {
console.log("value = " + attr.id);
}
});
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)
}
}
});