0

I want to hide and create elements that are loaded by AngularJS.

The DOM is not entirely loaded when I'd like to execute my JS functions.

Issue : my query selector is not able to detect elements. And I don't want to use a timeout because it depends to the network of the user.

My code :

app.controller('RootController', function($scope, $http, $filter) {
  $scope.init = function() {
    // NULL here, but after dom loaded in the chrome console I get an array of elements
    console.log(document.querySelectorAll('table .actionslist'));
  }
});
tonymx227
  • 4,933
  • 16
  • 45
  • 81

1 Answers1

0

You can use the following code;

This will add a listener on viewContentLoaded and will execute the code inside it when DOM is fully loaded.

$scope.$on('$viewContentLoaded', function () {  
    console.log(document.querySelectorAll('table .actionslist'));
});
georgeawg
  • 47,985
  • 13
  • 70
  • 91
Ajinkya Bodade
  • 331
  • 3
  • 9