我正在摆弄 AngularJS,并且必须包含一个名为flipclock.js的 jQuery 插件。我用谷歌搜索了很多,发现这篇关于在 Angular 指令中包装 jQuery 的文章。
我看着它并做了同样的事情flipclock
- 看起来像这样
var app = angular.module('flipClock', []);
app.directive('FlipClock', function(){
return {
restrict: 'A',
link: function(scope, element, attrs){
$(element).FlipClock(scope.$eval(attrs.FlipClock));
}
}
});
带有以下标记
<div ng-App="flipClock">
<div id="countdown" class="countdown" flipclock="{}"></div>
</div>
但什么也没发生,我得到错误:
Uncaught ReferenceError: Base is not defined - flipclock.js:37
:37 只是FlipClock.Base = Base.extend({ ...
我的html中源代码的顺序是:
<script src="components/jquery/jquery.js"></script>
<script src="components/angular/angular.js"></script>
<script src="components/angular-resource/angular-resource.js"></script>
<script src="components/angular-cookies/angular-cookies.js"></script>
<script src="components/angular-sanitize/angular-sanitize.js"></script>
<!-- build:js scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
<script src="scripts/controllers/pre.js"></script>
<!-- endbuild -->
<!-- build:js scripts/main.js -->
<script src="components/flipclock/libs/prefixfree.min.js"></script>
<script src="components/flipclock/flipclock.js"></script>