gpt4 book ai didi

javascript - 由于 :,无法实例化模块 ngAnimate

转载 作者:行者123 更新时间:2023-12-02 17:24:18 27 4
gpt4 key购买 nike

我在构建 Angular JS 项目时遇到问题。

它说无法实例化模块 ngAnimate,原因是:

我已将所有服务放入 [] 中,但 ngAnimate 无法正常工作。

这是应用程序

无法实例化模块 ngAnimate,原因是:“use strict”;

/* global app:true */

var app = angular
.module('angNewsApp', [
'ngCookies',
'ngResource',
'ngSanitize',
'ngRoute',
'ngAnimate',
'firebase'
])
.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/posts.html',
controller: 'PostsCtrl'
})
.when('/posts/:postId', {
templateUrl: 'views/showpost.html',
controller: 'ViewPostCtrl'
})
.otherwise({
redirectTo: '/'
});
}])

.constant('FIREBASE_URL', 'https://scorching-fire-4068.firebaseio.com/');

app.directive('post', function() {
var controller = function($scope) {
$scope.showAnswer = false;
};

return {
restrict: 'C',
scope: false,
controller: controller
};
});

app.animation('.answer-animation', function(){

CSSPlugin.defaultTransformPerspective = 1000;

TweenMax.set($("div.back"), {rotationX:-180});

$.each($("div.box"), function(i,element)
{
console.log(element);
var frontCard = $(this).children("div.front")
var backCard = $(this).children("div.back")
var tl = new TimelineMax({paused:true})

tl
.to(frontCard, 1, {rotationX:180})
.to(backCard, 1, {rotationX:0},0)

this.animation = tl;
});

return {
beforeAddClass: function(element, className, done){
if (className == 'answer') {
var el = element.find('.box')[0];
el.animation.play();
}
else {
done();
}
},

beforeRemoveClass: function(element, className, done) {
if (className == 'answer') {
var el = element.find('.box')[0];
el.animation.reverse();
}
else {
done();
}
}
};
});

以及index.html脚本标签

 <!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/firebase/firebase.js"></script>
<script src="bower_components/firebase-simple-login/firebase-simple-login.js"></script>
<script src="bower_components/angularfire/angularfire.js"></script>
<!-- endbower -->
<!-- endbuild -->

<!-- build:js({.tmp,app}) scripts/scripts.js -->
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.16/angular-animate.js"></script>
<script src="scripts/app.js"></script>
<script src='scripts/services/posts.js'></script>
<script src="scripts/filters/url.js"></script>
<script src="scripts/controllers/posts.js"></script>
<script src="scripts/controllers/postview.js"></script>
<script src="scripts/controllers/nav.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.11.7/TweenMax.min.js"></script>

<!-- endbuild -->

最佳答案

好的,这就是答案,

<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.16/angular-animate.js"></script>

<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.11.7/TweenMax.min.js"></script>

都是外部库加载,这意味着它们无法完成缩小过程。

我通过 Bower 安装库并像这样添加它们来解决这个问题。

<script src="/bower_components/angular-animate/angular-animate.js"></script>
<script src="/bower_components/greensock/src/minified/TweenMax.min.js"></script>

关于javascript - 由于 :,无法实例化模块 ngAnimate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23634393/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com