本文介绍了AngularJS误差注入modulerr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行此AngularJS教程的例子和控制台说:未捕获的错误:[$喷油器:modulerr]

问题出在哪里?

 < D​​IV CLASS =容器数据-NG-应用=demoApp>
    < D​​IV>
        < H3>添加模块配置和路由< / H3 GT&;        < D​​IV数据-NG-视图=>< / DIV>
    < / DIV>
< / DIV>  &所述; SCRIPT SRC =角1.2.3 / angular.min.js>&下; /脚本>
  &所述; SCRIPT SRC =角1.2.3 /角route.min.js>&下; /脚本><脚本>
    变种demoApp = angular.module('demoApp',['ngRoute']);    demoApp.config(函数($ routeProvider){
        $ routeProvider
            。什么时候('/',
                {
                    控制器:'SimpleController',
                    templateUrl:urlBase +'7。 Partial1.html
                })            。当('/ partial2',
                {
                    控制器:'SimpleController',
                    templateUrl:部分/ view1.html
                })
            不然的话({redirectTo:'/'});
    });    demoApp.controller('SimpleController',函数($范围){
        $ scope.customers = [
            {名称:'戴维·琼斯,都市:凤凰},
            {名称:'杰米·莱利,城市:'亚特兰大'},
            {名称:'Heedy Wahlin,城市:钱德勒},
            {名称:'托马斯冬天',城市:'西雅图'}
        ];
    });
< / SCRIPT>


解决方案

您需要删除 = NG-视图属性。

I'm trying to run this AngularJS example of a tutorial and the console says: Uncaught Error: [$injector:modulerr]

Where is the problem?

<div class="container" data-ng-app="demoApp">
    <div>
        <h3>Adding Module Configuration and Routing</h3>

        <div data-ng-view=""></div>
    </div>
</div>

  <script src="angular-1.2.3/angular.min.js"></script>
  <script src="angular-1.2.3/angular-route.min.js"></script>

<script>
    var demoApp = angular.module('demoApp', ['ngRoute']);

    demoApp.config(function ($routeProvider) {
        $routeProvider
            .when('/',
                {
                    controller: 'SimpleController',
                    templateUrl: urlBase + '7. Partial1.html'
                })

            .when('/partial2',
                {
                    controller: 'SimpleController',
                    templateUrl: 'Partial/view1.html'
                })
            .otherwise({ redirectTo: '/' });
    });

    demoApp.controller('SimpleController', function ($scope) {
        $scope.customers = [
            { name: 'Dave Jones', city: 'Phoenix' },
            { name: 'Jamie Riley', city: 'Atlanta' },
            { name: 'Heedy Wahlin', city: 'Chandler' },
            { name: 'Thomas Winter', city: 'Seattle' }
        ];
    }); 
</script>
解决方案

You need to remove the ="" from the ng-view attribute.

这篇关于AngularJS误差注入modulerr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 20:35