-1

I am loading content with ng-repeat. Javascript that is being loaded to that page and should interact with this content is not working. Can someone explain why and what is the best practice of placing custom scripts.

I suppose that's because JS is loaded before ng-repeat generated the content.

jonny pixel
  • 247
  • 6
  • 12
  • Please post some relevant code, otherwise it is impossible to tell what is happening. – Davin Tryon Feb 24 '15 at 16:47
  • 1
    something like that? use a directive to see when ng-repeat finished http://stackoverflow.com/questions/15207788/calling-a-function-when-ng-repeat-has-finished – hwsw Feb 24 '15 at 16:56

1 Answers1

1

Keep in mind that anything rendered by AngularJS is done after the document.ready event fires. Thus, any scripts that rely on that event to scan the DOM and look for things to interact with will do so before Angular has had a chance to place those items.

The solution to this will vary depending on the library. If the library allows for delayed action, you may be able to create a directive that calls the appropriate script once it has rendered out the appropriate nodes.

In general, when trying to integrate non-angular JS with angular, you will need to create some type of adapter, whether it be a directive or a service.

Dylan Watt
  • 3,307
  • 11
  • 16
  • I am working on UI prototype, so most functionally is done using jQuery. Can you maybe provide some example of delayed action implementation? – jonny pixel Feb 24 '15 at 19:43