无法在Angular js中实例化模块错误 [英] Failed to instantiate module error in Angular js

查看:55
本文介绍了无法在Angular js中实例化模块错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到以下错误,其根本原因是模块'ngRoute'不可用

I encountered the following error with a root cause of Module 'ngRoute' is not available


Uncaught错误:[$ injector:modulerr]无法实例化模块
Amail由于:

Uncaught Error: [$injector:modulerr] Failed to instantiate module Amail due to:

错误:[$ injector:modulerr]无法实例化模块ngRoute到期
to:

Error: [$injector:modulerr] Failed to instantiate module ngRoute due to:

错误:[$ injector:nomod]模块'ngRoute'不可用!您要么
拼错了模块名称,要么忘记加载它。如果注册
模块,请确保将依赖项指定为第二个
参数。

Error: [$injector:nomod] Module 'ngRoute' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument."

Javascript代码:

Javascript code :

var amailServices = angular.module('Amail',['ngRoute']);
function emailRouteConfig($routeProvider) {
$routeProvider.
    when('/', {
        controller: ListController,
        templateUrl : 'list.html'}).

    when('/view/:id',{
        controller : DetailsController,
        templateUrl:'detail.html'}).

    otherwise({
        redirectTo:'/'
    });
}
amailServices.config(emailRouteConfig);

如何解决这个问题

推荐答案

你需要包含 angular-route.js 在您的HTML中:

You need to include angular-route.js in your HTML:

<script src="angular-route.js">

http://docs.angularjs.org/api/ngRoute

这篇关于无法在Angular js中实例化模块错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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