URL中的ui-router向导ID

时间:2014-06-06 20:54:35

标签: angularjs angular-ui-router

我有一个基于向导的流程来创建报价。我正在使用angularjs ui-router来管理向导网址。下面显示的路线非常适合创建新报价。我现在需要返回编辑现有引号,并需要弄清楚如何在URL中使用ID。我在想类似baseUrl / quote#/ 3 / options(引用#3选项步骤)。目前,网址看起来像baseUrl / quote#/ options。如果我将.state定义中的url从url:'options'更改为url:':quoteId / options',它会中断我的路由(无法再进入选项步骤)。这也不适用于新报价,因为它还没有ID。什么是让它发挥作用的最佳方式?

quoteWizardModule.config(['$stateProvider', function ($stateProvider) {
    $stateProvider
        .state('wizard', {
            url: '',
            templateUrl: 'Scripts/templates/quoteWizard/wizardLayout.html',
            controller: 'wizardNavigationCtrl'
        })
        .state('wizard.options', {
            url: 'options',
            templateUrl: 'Scripts/templates/quoteWizard/wizardOptions.html',
            controller: 'wizardOptionsCtrl'
        })
        .state('wizard.newmodel', {
            url: 'newmodel',
            templateUrl: 'Scripts/templates/quoteWizard/wizardModel.html',
            controller: 'wizardModelCtrl',
        })
        .state('wizard.model', {
            url: 'model/:factoryId/:index',
            templateUrl: 'Scripts/templates/quoteWizard/wizardModel.html',
            controller: 'wizardModelCtrl'
        })
        .state('wizard.other', {
            url: 'other',
            templateUrl: 'Scripts/templates/quoteWizard/wizardOther.html',
            controller: 'wizardOtherCtrl'
        })
        .state('wizard.customer', {
            url: 'customer',
            templateUrl: 'Scripts/templates/quoteWizard/wizardCustomer.html',
            controller: 'wizardCustomerCtrl'
        })
        .state('wizard.shipping', {
            url: 'shipping',
            templateUrl: 'Scripts/templates/quoteWizard/wizardShipping.html',
            controller: 'wizardShippingCtrl'
        })
        .state('wizard.notes', {
            url: 'notes',
            templateUrl: 'Scripts/templates/quoteWizard/wizardNotes.html',
            controller: 'wizardNotesCtrl'
        })
        .state('wizard.review', {
            url: 'review',
            templateUrl: 'Scripts/templates/quoteWizard/wizardReview.html',
            controller: 'wizardReviewCtrl'
        });
}]);

0 个答案:

没有答案