Dims
Dims

Reputation: 51059

How to include angular-ui-slider into my application? (TypeError: elm.slider is not a function)

What are modern instructions to include angular-ui-slider?

I did

bower install angular-ui-slider --save

then included additionally

  <script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script>
  <script type="text/javascript" src="bower_components/jquery-ui/ui/jquery-ui.js"></script>
  <script type="text/javascript" src="bower_components/jquery-ui/ui/jquery.ui.slider.js"></script>
  <script type="text/javascript" src="bower_components/angular-ui-slider/src/slider.js"></script>

and also added dependency in app.js

var pdkApp = angular.module('pdkApp', [
  'ngRoute',
  'pdkControllers',
...
  'ui.slider'
]);

but have the following error:

TypeError: elm.slider is not a function
    at init (slider.js:45)
    at slider.js:54
    at angular.js:7478
    at Scope.$eval (angular.js:16052)
    at Scope.$digest (angular.js:15870)
    at Scope.$apply (angular.js:16160)
    at done (angular.js:10589)
    at completeRequest (angular.js:10787)
    at XMLHttpRequest.requestLoaded (angular.js:10728)

Upvotes: 0

Views: 741

Answers (1)

ChrisY
ChrisY

Reputation: 1783

When do you load angular.js? You need to load it before slider.js

<script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="bower_components/jquery-ui/ui/jquery-ui.js"></script>
<script type="text/javascript" src="bower_components/angular/angular.js"></script>
<script type="text/javascript" src="bower_components/angular-ui-slider/src/slider.js"></script>

example: http://jsfiddle.net/6xta5pd0/

Upvotes: 1

Related Questions