未捕获的错误:[$喷油器:modulerr]在使用angularJS [英] Uncaught Error: [$injector:modulerr] when using angularJS

查看:151
本文介绍了未捕获的错误:[$喷油器:modulerr]在使用angularJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用angularJS在我的应用程序,但是当我添加配置节路由我得到这个错误:

I'm using angularJS in my application but when I add config section for routing I'm get this error :

Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.9/$injector/modulerr?p0=demoApp&p1=Error%3A…nts%2FGitHub%2FSirwanAfifi.github.io%2Fscripts%2Fangular.min.js%3A32%3A232)

这是我的code:

var demoApp = angular.module('demoApp', []);

demoApp.config(function ($routeProvider) {
            $routeProvider
                .when('/',
                    {
                        controller: 'CustomerController',
                        templateUrl: 'views/view1.html'
                    })
                .when('/view1',
                    {
                        controller: 'CustomerController',
                        templateUrl: 'views/view1.html'
                    })
                .otherwise({redirectTo:'/'});
});

我发现这个答案,但我不使用角-route.min.js ,我只是想在我的应用程序中使用简单的路线。

I found this answer but I'm not using angular-route.min.js, I just want to use simple route in my application.

推荐答案

好吧,我同意的意见,其余的 - 你肯定需要ngRoute依赖和角route.js或角route.min.js文件包括在内。这是因为$ routeProvider这些文件内声明。 AngularJS队的想法是在框架的不同逻辑部分分开,使它们独立,从而使得可以使用框架的某些部分在应用程序中或框架以及将来在服务器侧(使用它的节点的能力。 js的环境)。一些旧的previous版本并不需要对包括独立的文件和依赖。现在是强制性的。

Well, I agree with the rest of the comments - you definitely need ngRoute dependency and angular-route.js or angular-route.min.js file included. It's because $routeProvider is declared inside of those files. The idea of AngularJS team was to separate the different logic parts of the framework, make them independent and thus making possible to use some parts of the frameworks in your applications or frameworks as well as future ability to use it at the server side (Node.js environment). Some old previous versions didn't require to include separate files and dependencies. For now that is obligatory.

这篇关于未捕获的错误:[$喷油器:modulerr]在使用angularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆