Mad*_*Mad 7 html javascript angularjs
我需要从AngularJs获取Element ID.
我试过这个但是没用.
angular.module('AngStarter').directive('oblInLineEditor', function() {
return function(scope, element, attr) {
console.log("value = " + scope.$eval(attr.id));
}
});
Run Code Online (Sandbox Code Playgroud)
SSH*_*SSH 13
你这里不需要scope.eval.
angular.module('AngStarter').directive('oblInLineEditor', function() {
return function(scope, element, attr) {
console.log("value = " + attr.id);
}
});
Run Code Online (Sandbox Code Playgroud)
参见以下示例: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)
}
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12919 次 |
| 最近记录: |