我对角度js错误感到不安 angular.js:36未捕获错误:[$ injector:modulerr] http://errors.angularjs.org/1.2.19/ $ injector / modulerr?p0 = app& p1 =错误%3A%20 ... gleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.19% 2Fangular.min.js%3A18%3A139)
index.php代码是
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js"></script>
<script src="http://code.angularjs.org/1.2.17/angular-animate.js"></script>
<link rel="stylesheet" href="<?php bloginfo('template_url')?>/style.css" />
<script src="<?php bloginfo('template_url')?>/angular-animate.js"></script >
<script src="<?php bloginfo('template_url')?>/script.js"></script>
</head>
<body ng-controller="Ctrll">
<p style="color:#000;margin:0"><span>slide:</span>{{slide}} </p>
<button ng-click="showAlerts()" style="float:left">
click to toggle panel
</button>
<!--sliding panel directive-->
<alerts-center ng-if="parentslide"></alerts-center>
</body>
</html>
js代码是
angular.module("app",["ngAnimate"])
.controller("Ctrll",function($scope, $timeout){
$scope.parentslide =false;
$scope.showAlerts = function($event) {
$scope.parentslide =true;
$timeout(function(){
$scope.$broadcast('openAlerts');
},1)
}
})
.controller('alertsCtrl', function ($scope) {
$scope.$on('openAlerts', function(event, args) {
$scope.slide = !$scope.slide;
});
})
.directive('alertsCenter', function () {
return {
templateUrl: 'alerts.php',
replace:true,
restrict: 'E',
controller:'alertsCtrl'
};
});
答案 0 :(得分:1)
如果你在plunker工作它的罚款。如果没有,那么错误可能是由于
<script data-require="angular.js@1.2.20" data-semver="1.2.19" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js"></script>
<script data-require="angular-animate@1.2.17" data-semver="1.2.17" src="http://code.angularjs.org/1.2.17/angular-animate.js"></script>
data-require和data-semver实际上是Plunker的特定实现。
更好用: bower安装angular-animate 并添加脚本标记
< script src="/bower_components/angular-animate/angular-animate.js"></script >
最后依赖注入
angular.module('myApp', ['ngAnimate']);