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

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

包含 angular-ui-滑块的现代指令是什么?

我做到了

bower install angular-ui-slider --save

然后额外包含

  <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>

并且还在 app.js

中添加了依赖项
var pdkApp = angular.module('pdkApp', [
  'ngRoute',
  'pdkControllers',
...
  'ui.slider'
]);

但出现以下错误:

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)

你什么时候加载angular.js?您需要在 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>

示例: http://jsfiddle.net/6xta5pd0/