0

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 ?

1

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

In my project, each report is a chart and when it is loaded, I need to execute a jquery function like $(".showhideWIdget").showhide();
you can simply do that using ng-show/ng-hide directive. Or you can put this in your controller also. But since you are using angular avoid using jquery as much as possible. make it all consistent with the angular
the showhide function is a custom data-widget processing js function that I need to follow as per company standard.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.