AngularJS element[removed] is undefined from within directive

前端 未结 1 2073
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-07 10:21

Let\'s say I have:

directives.directive(\'foo\', function () {
    return {
        restrict:\'A\',
        scope: true,
        link:function (scope, element, a         


        
相关标签:
1条回答
  • 2021-02-07 10:50

    The element variable that is passed to your link function is a jqLite object - not a DOM object. You can obtain the DOM object with element[0] (like you could in jQuery), but jqLite provides a method for you: element.html(). Check out the docs.

    0 讨论(0)
提交回复
热议问题