AngularJS-1.4抛出$ injector:使用`angular-adaptive-templating`的unpr错误

时间:2015-06-20 10:09:50

标签: jquery html angularjs

在我的应用程序中,名为responsive,对于我正在使用matchmedia-ng的控制器,对于模板我使用angular-adaptive-templating使用此repo与AngularJS版本1.4.1

但我收到的错误是:

  

http://errors.angularjs.org/1.4.1/$injector/unpr?p0=eProvider%20%3C-%20e%20%3C-%20%24http%20%3C-%20%24templateRequest%20%3C-%20%24compile

如何解决?或者只使用matchmedia-ng本身就可以处理adaptive-templating。请有人帮我解决这个问题。

提前致谢。

我的Js:

"user strict";

angular.module('responsive', ['ngRoute', 'matchmedia-ng', 'adaptiveTemplating'])

    .config(function ($routeProvider, $locationProvider) {

        $locationProvider.html5Mode(true);

        $routeProvider
            .when ("/", {
                templateUrl : "views/home.html",
                controller  : "homeController",
                reloadOnSearch: false
        });

        $routeProvider
            .otherwise ({
                redirectTo:'/',
                reloadOnSearch: false
        });
});

我的HTML:

<!DOCTYPE html>
<html ng-app="responsive">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>NG - Responsive</title>
    <link rel="stylesheet" media="screen and (min-width: 800px)"  href="css/desktop.css">
    <link rel="stylesheet" media="screen and (max-width: 799px)"  href="css/mobile.css">
    <!-- lib scripts -->
    <script src="bower_components/jquery/dist/jquery.min.js"></script>
    <script src="bower_components/angular/angular.min.js"></script>
    <script src="bower_components/angular-route/angular-route.min.js"></script>
    <script src="bower_components/angular-adaptive-templating/dist/angular-adaptive-templating.min.js"></script>
    <script src="bower_components/matchmedia-ng/matchmedia-ng.js"></script>
    <!-- script -->
    <script src="js/app.js"></script>
</head>
<body>
    <div ng-view ></div>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

来自AngularJS doc

  

此错误是因为$ injector无法解析a   必要的依赖。

您尝试在homeController中使用的代码似乎缺失$routeProvider