2017-06-15 140 views
1

目前我得到這個錯誤嘗試加載我的角度應用:

Uncaught Error: [$injector:unpr] Unknown provider: $$HashMapProvider <- $$HashMap <- $$animateQueue <- $animate <- $compile <- $$animateQueue http://errors.angularjs.org/1.6.4/ $injector/unpr?p0=%24%24HashMapProvider%2…eQueue%20%3C-%20%24animate%20%3C-%20%24compile%20%3C-%20%24%24animateQueue

錯誤的鏈接只是告訴我,我拼寫錯誤的東西,但經過四次檢查後,這不是問題。這裏是我的bower.json文件:

{ 
    "name": "angular-seed", 
    "description": "A starter project for AngularJS", 
    "version": "0.0.0", 
    "homepage": "https://github.com/angular/angular-seed", 
    "license": "MIT", 
    "private": true, 
    "dependencies": { 
    "angular": "^1.6.4", 
    "angular-route": "~1.5.0", 
    "angular-loader": "~1.5.0", 
    "angular-mocks": "~1.5.0", 
    "html5-boilerplate": "^5.3.0", 
    "angular-animate": "^1.6.4", 
    "angular-material": "^1.1.4" 
    } 
} 

這裏是我的angular.module這是在同我的兩個view1.jsview2.js

(function() { 
    var module = angular.module("myApp.view2", [ 
    "ngRoute", 
    "ngMaterial", 
    "ngAnimate", 
    "ngAria", 
    "ngMessages", 
    "mdPickers" 
    ]); 

    module.config(['$routeProvider', function($routeProvider) { 
    $routeProvider.when('/view2', { 
     templateUrl: 'view2/view2.html', 
     controller: 'View2Ctrl' 
    }); 
    }]); 

    module.controller("View2Ctrl", ['$scope', '$mdpDatePicker', '$mdpTimePicker', function($scope, $mdpDatePicker, $mdpTimePicker){ 
    $scope.currentDate = new Date(); 
    // controller code 
    }]); 
})(); 

的index.html

<!DOCTYPE html> 
<!--[if lt IE 7]>  <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> 
<!--[if IE 7]>   <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8"> <![endif]--> 
<!--[if IE 8]>   <html lang="en" ng-app="myApp" class="no-js lt-ie9"> <![endif]--> 
<!--[if gt IE 8]><!--> <html lang="en" ng-app="myApp" class="no-js"> <!--<![endif]--> 
<head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <title>My AngularJS App</title> 
    <meta name="description" content=""> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/normalize.css"> 
    <link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/main.css"> 
    <link rel="stylesheet" href="app.css"> 
    <script src="bower_components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js"></script> 
</head> 
<body> 
    <!--[if lt IE 7]> 
     <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p> 
    <![endif]--> 


    <ul class="menu"> 
    <li><a href="#!/view1">view1</a></li> 
    <li><a href="#!/view2">view2</a></li> 
    </ul> 


    <div ng-view></div> 

    <div>Angular seed app: <span app-version></span></div> 

    <script src="bower_components/angular/angular.js"></script> 
    <script src="bower_components/angular-route/angular-route.js"></script> 
    <!-- Angular Material requires Angular.js Libraries --> 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script> 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script> 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script> 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script> 
    <!-- Angular Material Library --> 
    <script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script><script src="app.js"></script> 
    <script src="https://cdn.rawgit.com/alenaksu/mdPickers/0.7.4/dist/mdPickers.min.js"></script> 
    <script src="view1/view1.js"></script> 
    <script src="view2/view2.js"></script> 
    <script src="components/version/version.js"></script> 
    <script src="components/version/version-directive.js"></script> 
    <script src="components/version/interpolate-filter.js"></script> 
</body> 
</html> 

我也有我的節點package.json依賴。這似乎不是這個特定問題的一部分,但如果需要,我可以添加該代碼。

我以前見過並問過這個問題,但沒有一個提供的解決方案有幫助,所以我現在正在自問。

這是github。目前在主分支上的版本引發了我的錯誤。 https://github.com/eanzalone/AngularDatePicker

+0

添加腳本,請提供您的index.html您在何處加載腳本 – jos

+1

在您的項目中使用ngAnimate的版本等於當前版本的Angular。角動畫是1.5.5。但角是1.6.4 – jos

+0

它看起來像你包括角*兩次*,一次通過涼亭和一次CDN鏈接,他們是兩個不同的版本。 – Claies

回答

1

確保您使用適當的版本 更新您的bower.json使用1.5.0版本的角度

{ 
    "name": "angular-seed", 
    "description": "A starter project for AngularJS", 
    "version": "0.0.0", 
    "homepage": "https://github.com/angular/angular-seed", 
    "license": "MIT", 
    "private": true, 
    "dependencies": { 
    "angular": "^1.5.0", 
    "angular-route": "~1.5.0", 
    "angular-loader": "~1.5.0", 
    "angular-mocks": "~1.5.0", 
    "html5-boilerplate": "^5.3.0", 
    "angular-animate": "^1.5.0", 
    "angular-material": "^1.1.4" 
    } 
} 

從涼亭的部件本身

相關問題