Search code examples
javascriptangularjsangularjs-components

AngularJs 1.6 Component Script inside tempalteUrl not executing


I have a script tag inside the angular component's template [report.template.html] and it is not being executed upon load.

  <script >
  $(document).ready(function() {
  console.log("calling showHide");
  });
  </script>

Note: Loaded the jquery lib before angularjs lib as shown in the below plunkr

https://plnkr.co/edit/u8XGlVlY9Q5DmKmPOQwA?p=preview

I know i must be missing something simple. Can someone please help where I am doing it wrong ?


Solution

  • Don't know is this what you looking for but you an use the angular.element(document).ready() method instead of jquery functions like this

    var reportController = function() {
       var ctrl = this;
          angular.element(document).ready(function () {
           console.log("calling showHide");
        });
          console.log("report ctrl");
    };
    

    Demo