Apply javascript to ng-include

Asked

Viewed 18 times

0

I’m using "ng-include" to add the menu on a page, it loads the menu, but the javascript stops working.

I don’t have much knowledge in Angularjs.

It’s like this in html:

<script src="/../js/angular.min.js" type="text/javascript" charset="UTF-8"></script>
<script src="/../js/angular-route.min.js" type="text/javascript" charset="UTF-8"></script>
    
<section ng-include src="'/../header.min.html'"></section>
    

<script>
   $('.navbar .dropdown .fa').on('click', function (){
   $(this).parent('li').children('.dropdown-menu').slideToggle();
   });
</script>

What I would have to do to run javascript?

1 answer

1

I believe you have this problem for misusing the ngInclude, if you check the documentation, the correct ways to use:

Or use as an element and set the path to the .html in the attribute src:

<ng-include src="'/../header.min.html'"></ng-include>

Or use as a directive, as it is already using, but assign path to the .html to the directive itself and not to a new attribute src:

<section ng-include="'/../header.min.html'"></section>
  • I didn’t succeed, I tried both ways.

  • Any error appears in the browser console?

  • No errors, just a source reference

Browser other questions tagged

You are not signed in. Login or sign up in order to post.