1

I've created a directive that makes an html scrollable (using Malihu scroller)

myApp.directive("scrollable", [function () {
    return function(scope, elm) {
        elm.mCustomScrollbar({
            autoHideScrollbar: false,
            theme: 'dark',
            advanced:{
                updateOnContentResize: true
            }
        });
    };
}]);

Here is the live example on Plunker : http://plnkr.co/edit/wm9qHn?p=preview

Is it stupid to use a directive to do this? Is there a better / more fancy way to make an element scrollable in Angular?

1 Answer 1

1

This is how Angular defines a directive:

...directives are markers on a DOM element... that tell AngularJS's HTML compiler to attach a specified behavior to that DOM element or even transform the DOM element and its children.

Your example sounds like an ideal use case for a directive, since you're adding functionality to an element.

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.