Angular UI_ROUTER无法解析' newUser'来自州'登录'

时间:2015-08-29 15:48:18

标签: javascript angularjs routing angular-ui-router

我尝试使用ui.routing但使用stateProvider我收到错误:Could not resolve 'newUser' from state 'login'。 这是我的配置:

的index.html

<html lang="en" ng-app="mainApp">
    <section id="mainBody">
        <div class="continer">
            <div>
                <a ui-sref="main">Header</a>
                <a ui-sref="login">Login</a>
                <a ui-sref="list2">List2</a>
            </div>
            <div class="row" ui-view></div>
            <div>Footer</div>
        </div>
    </section>
</html>

index.js

var mainApp = angular.module('mainApp', [, 'ui.router', 'ui.bootstrap']);

mainApp.config(['$stateProvider', function ($stateProvider) {
    $stateProvider.state('login', {
        url: 'login',
        templateUrl: '../../pages/login.html'
    });
}]);

的login.html

<!DOCTYPE html>
<html lang="en" ng-app="loginApp">
<body>
    <section id="form">
        <!--form-->
        <div class="container login-user">
            <div class="row">
                <a type="button" class="btn btn-loginUser btn-default col-xs-12 col-sm-2" ui-sref="existingUser">Existing user</a>
                <a type="button" class="btn btn-loginUser btn-default col-xs-12 col-sm-2" ui-sref="newUser">New user</a>
            </div>
            <div class="row" ui-view="userInfo">
            </div>
        </div>
    </section>
</body>
</html>

login.js

var loginApp = angular.module('loginApp', ['ui.router', 'ngSanitize', 'ui.bootstrap']);

loginApp.config(['stateProvider', function (stateProvider) {
    $stateProvider
        .state('existingUser', {
            views: {
                "userInfo": {
                    url: 'existinguser',
                    templateUrl: '../../pages/loginForms/existingUserForm.html',
                    controller: 'existingUserCtrlr'
                }
            }
        })
        .state('newUser', {
            views: {
                "userInfo": {
                    url: 'newUser',
                    templateUrl: '../../pages/loginForms/newUserForm.html',
                    controller: 'newUserCtrlr'
                }
            }
        });
}]);

也许有人可以告诉我我错过了什么?

1 个答案:

答案 0 :(得分:0)

void DoSomehtingCool() { var factory = new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext()); factory.StartNew(() => { var result = await IntensiveComputing(); txtLog.AppendText("Result of the computing: " + result); }); } async Task<double> IntensiveComputing() { Thread.Sleep(5000); return 20; } loginApp是两个不同的模块。您无法从mainApp转到newUser,因为在login上定义了login。而在mainApp上定义了其他两条路线。定义同一模块上的所有路由。