小编bec*_*cki的帖子

错误:[$ injector:unpr]未知提供者:$ stateProvider

我试图使用ui.router时遇到错误:

Uncaught Error: [$injector:modulerr] Failed to instantiate module bApp due to:
Error: [$injector:unpr] Unknown provider: $stateProvider
http://errors.angularjs.org/1.4.5/$injector/unpr?p0=%24stateProvider
at REGEX_STRING_REGEXP (http://localhost:9000/bower_components/angular/angular.js:68:12)
at http://localhost:9000/bower_components/angular/angular.js:4284:19
at getService (http://localhost:9000/bower_components/angular/angular.js:4432:39)
at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4464:13)
at runInvokeQueue (http://localhost:9000/bower_components/angular/angular.js:4379:35)
at http://localhost:9000/bower_components/angular/angular.js:4388:11
at forEach (http://localhost:9000/bower_components/angular/angular.js:336:20)
at loadModules (http://localhost:9000/bower_components/angular/angular.js:4369:5)
at createInjector (http://localhost:9000/bower_components/angular/angular.js:4294:11)
at doBootstrap (http://localhost:9000/bower_components/angular/angular.js:1655:20)
http://errors.angularjs.org/1.4.5/$injector/modulerr?p0=bApp&p1=Error%3A%20…F%2Flocalhost%3A9000%2Fbower_components%2Fangular%2Fangular.js%3A1655%3A20)
Run Code Online (Sandbox Code Playgroud)

angular.module('bApp', ['ui.router']);
angular.module('bApp').config(function($stateProvider, $urlRouterProvider) {
    urlRouterProvider.otherwise('/');

    $stateProvider
        .state('main', {
            url: "/",
            templateUrl: "/views/main.html"
        })

    .state('register', {
        url: "/register",
        templateUrl: "/views/register.html"
       
    });
});
Run Code Online (Sandbox Code Playgroud)
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="description" content="">
    <meta name="viewport" …
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ui-router

6
推荐指数
2
解决办法
8896
查看次数

标签 统计

angular-ui-router ×1

angularjs ×1