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

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

问题描述

我试图使用路由使用通过URL来传递参数的 ui.router 但是我卡在第一关,因为我似乎无法得到UI的路由器注册,所以我得到了下面的错误。

I'm trying to use a route to pass parameters via the url using ui.router however i'm stuck at the first hurdle as i can't seem to get the ui-router to register so i get the following error.

Uncaught Error: [$injector:modulerr]

我包括我的ui.router JS在配置文件看起来是这样的文件:
'./编译/ lib目录/ UI路由器/发行/角-UI-router.min.js

然后我包括 ui.router 我的模块中:

I then include ui.router in my module:

topic.Module = angular.module('topic', ['ui.router']);

和尝试创建像这样一个样品状态:

and try to create a sample state like so:

topic.Module.config(['$stateProvider', function($stateProvider) {
    $stateProvider
        .state('app', {
            url: '/'
        });
}]);

有什么明显的,我做或不这样做,将导致此不工作或得到上面的错误?我剪了状态的内容完全关闭,以确认没有别的导致错误。

Is there anything obvious that i'm doing or not doing that would result in this not working or getting the above error? I've cut the contents of the state down completely to confirm nothing else was causing the error.

我试过,包括UI路由器而不是'ui.router 我已经包括在主程式模块也具有相同的效果。

I've tried including 'ui-router' instead of 'ui.router' i've included in the main app module also with the same results.

推荐答案

任何人碰到这个即将到来,似乎 $ urlRouterProvider 要求以及 $ stateProvider

for anyone coming across this, it seems $urlRouterProvider is required as well as $stateProvider.

因此​​包括 $ urlRouterProvider 并添加以下设置缺省路由
$ urlRouterProvider.otherwise('/');

So include $urlRouterProvider and add the following to set a default route: $urlRouterProvider.otherwise('/');

所以上面的例子是这样的:

so the above example would look like this:

topic.Module.config(['$stateProvider', '$urlRouterProvider'  function($stateProvider, $urlRouterProvider) {
    $urlRouterProvider.otherwise('/');
    $stateProvider
        .state('app', {
            url: '/'
        });
}]);

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

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