未捕获错误:[$ injector:unpr]未知提供商:

时间:2017-06-15 03:21:57

标签: javascript angularjs bower angular-module

我目前在尝试加载我的Angular App时遇到此错误:

  

未捕获错误:[$ injector:unpr]未知提供者:$$ HashMapProvider   &lt; - $$ HashMap&lt; - $$ animateQueue&lt; - $ animate&lt; - $ compile&lt; -   $$ animateQueue   http://errors.angularjs.org/1.6.4/ $注射器/ unpr?P0 =%24%24HashMapProvider%2 ... eQueue%20%3 C-%20%24animate%20%3 C-%20%24compile%20%3 C-%20%24%24animateQueue < / p>

错误中的链接只是告诉我拼写错误,但经过四重检查后,这不是问题所在。这是我的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 }]); })(); 相同
<!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>

的index.html

package.json

我的节点依赖项也有/* * write data to internal flash * return: value if OK, 0 if Error */ uint32_t WriteToFlash(uint32_t address, uint32_t value) { uint32_t PAGEError = 0; uint32_t result = 0; /* Unlock the Flash to enable the flash control register access *************/ HAL_FLASH_Unlock(); /* Erase the user Flash area */ EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES; EraseInitStruct.PageAddress = FLASH_USER_START_ADDR; //User defined addr EraseInitStruct.NbPages = 1; if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK) { HAL_FLASH_Lock(); return 0; } /* Program the user Flash area word by word */ if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, value) != HAL_OK) { HAL_FLASH_Lock(); return 0; } /* Lock the Flash to disable the flash control register access (recommended to protect the FLASH memory against possible unwanted operation) *********/ HAL_FLASH_Lock(); /* Check if the programmed data is OK */ result = *(__IO uint32_t *)address; if(result != value) return 0; return result; } 。这似乎不是这个特定问题的一部分,但我可以根据要求添加该代码。

我之前见过并问过这个问题,但所提供的解决方案都没有帮助,所以我现在就自己问了。

这是github。抛出错误的版本目前在Master Branch上。 https://github.com/eanzalone/AngularDatePicker

1 个答案:

答案 0 :(得分: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"
  }
}

从凉亭组件本身添加脚本