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
  • 5,293
  • 16
  • 48
  • 91

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
  • 48,608
  • 13
  • 72
  • 95
Ajinkya Bodade
  • 491
  • 1
  • 5
  • 11