-1

Here is my code I want to recall $('.ams-items').slimScroll() function

angular.element(document).ready(function () {
  $('.ams-items').slimScroll({
    alwaysVisible: true
  });
}); 

Please help me!

1

1 Answer 1

1

How to Encapsulate jQuery code in a Custom Directive1

Any jQuery code that manipulates the DOM should be encapsulated in a custom directive so that it is executed when the AngularJS framework instantiates the element.

app.directive("mySlimScroll", function()
     return {
         link: postLink,
     };
     function postLink(scope,elem,attrs) {
         elem.slimScroll({
             alwaysVisible: true
         });
     }
});

Usage:

<div class="ams-items" my-slim-scroll>
</div>

To use jQuery, simply ensure it is loaded before the angular.js file.

For more information, see

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.