AngularJS accessing DOM elements inside directive template

后端 未结 3 631
遥遥无期
遥遥无期 2021-01-30 10:19

Is there a more \"angular\" way of selecting DOM elements inside a directive template? For example, say you have this directive:

app.directive(\"myDirective\", f         


        
3条回答
  •  北荒
    北荒 (楼主)
    2021-01-30 10:39

    I don't think there is a more "angular way" to select an element. See, for instance, the way they are achieving this goal in the last example of this old documentation page:

    {
         template: '
    ' + '
    {{title}}
    ' + '
    ' + '
    ', link: function(scope, element, attrs) { // Title element var title = angular.element(element.children()[0]), // ... } }

提交回复
热议问题