czy istnieje funkcja oddzwaniania po renderowaniu dla dyrektywy Angular JS?

Właśnie dostałem dyrektywę, aby pobrać szablon, aby dołączyć go do tego elementu:

# CoffeeScript
.directive 'dashboardTable', ->
  controller: lineItemIndexCtrl
  templateUrl: "<%= asset_path('angular/templates/line_items/dashboard_rows.html') %>"
  (scope, element, attrs) ->
    element.parent('table#line_items').dataTable()
    console.log 'Just to make sure this is run'

# HTML
<table id="line_items">
    <tbody dashboard-table>
    </tbody>
</table>

Używam także wtyczki jQuery o nazwie DataTables. Ogólne użycie jest takie: $ ('table # some_id'). DataTable (). Możesz przekazać dane JSON do wywołania dataTable (), aby dostarczyć dane tabeli LUB możesz mieć dane już na stronie i zrobi resztę. Robię to drugie, mając wiersze już na stronie HTML .

Ale problem polega na tym, że muszę wywołać funkcję dataTable () w tabeli # line_items PO DOM DOM. Moja dyrektywa powyżej wywołuje metodę dataTable () PRZED dodaniem szablonu do elementu dyrektywy. Czy istnieje sposób na wywołanie funkcji PO dołączeniu?

Dziękuję za pomoc!

AKTUALIZACJA 1 po odpowiedzi Andy'ego:

Chcę się upewnić, że metoda linku zostanie wywołana tylko po tym, jak wszystko jest na stronie, więc zmieniłam dyrektywę na mały test:

# CoffeeScript
#angular.module(...)
.directive 'dashboardTable', ->
    {
      link: (scope,element,attrs) -> 
        console.log 'Just to make sure this gets run'
        element.find('#sayboo').html('boo')

      controller: lineItemIndexCtrl
      template: "<div id='sayboo'></div>"

    }

I rzeczywiście widzę „boo” w div # sayboo.

Następnie próbuję wywołania datatable jquery

.directive 'dashboardTable',  ->
    {
      link: (scope,element,attrs) -> 
        console.log 'Just to make sure this gets run'
        element.parent('table').dataTable() # NEW LINE

      controller: lineItemIndexCtrl
      templateUrl: "<%= asset_path('angular/templates/line_items/dashboard_rows.html') %>"
    }

Nie ma szczęścia

Następnie próbuję dodać limit czasu:

.directive 'dashboardTable', ($timeout) ->
    {
      link: (scope,element,attrs) -> 
        console.log 'Just to make sure this gets run'
        $timeout -> # NEW LINE
          element.parent('table').dataTable()
        ,5000
      controller: lineItemIndexCtrl
      templateUrl: "<%= asset_path('angular/templates/line_items/dashboard_rows.html') %>"
    }

I to działa. Zastanawiam się więc, co poszło nie tak w wersji bez kodu czasowego kodu?

questionAnswers(10)

yourAnswerToTheQuestion