3

I am trying angular + scrollbar [https://github.com/iominh/ng-scrollbars], however not able to make it work. It just gives module error and show text. in codepen it doesn't even show text. any help Plunker and codepan

<html>

<head>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.0/jquery.mCustomScrollbar.min.css" type="text/css" />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.0/jquery.mCustomScrollbar.concat.min.js"></script>
  <script src="https://raw.githubusercontent.com/iominh/ng-scrollbars/master/src/scrollbars.js"></script>
  <script>
    var app = angular.module('app', ['ngScrollbars']);
    app.config(function(ScrollBarsProvider) {
      // scrollbar defaults
      ScrollBarsProvider.defaults = {
        autoHideScrollbar: false,
        setHeight: 100,
        scrollInertia: 0,
        axis: 'yx',
        advanced: {
          updateOnContentResize: true
        },
        scrollButtons: {
          scrollAmount: 'auto', // scroll amount when button pressed
          enable: true // enable scrolling buttons by default
        }
      };
    });

    function MainController($scope) {
      // example of overriding defaults per scrollbar
      $scope.scrollbarConfig = {
        theme: 'dark',
        scrollInertia: 500
      }
    }

    app.controller('mainCtrl', MainController);
  </script>
</head>

<body ng-app="app" ng-controller="mainCtrl">

  <div style="width: 200px;" ng-scrollbars ng-scrollbars-config="scrollbarConfig">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ornare magna ultrices tincidunt tincidunt. Donec sagittis lorem placerat iaculis vehicula. Nunc bibendum quam vel rutrum rutrum. Duis nunc dolor, vehicula vitae pulvinar eu, semper vitae eros.
    Proin auctor, felis placerat posuere dictum, massa ipsum fermentum ipsum, sit amet tincidunt metus justo ut dui. Curabitur aliquet tempor dolor eget volutpat. Proin consequat metus id justo interdum, id porta justo venenatis. Nullam vel tristique
    neque, at luctus velit. Nulla sit amet convallis felis.
  </div>

</body>

</html>

1 Answer 1

3

Updated your codepen with 3 changes: codepen

  1. Updated link to ngscrollbars file: github doesn't allow the files to be used as script directly, change host to rawgit.com will do

https://rawgit.com/iominh/ng-scrollbars/master/src/scrollbars.js

  1. You misspelled the directive: ng-scrollbars (note the last 's')

  2. The height CSS needs to be in the same level with the directive.

<ul ng-scrollbars style = "height: 100px;">

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.