我有这个代码(继承了一个应用程序)
angular.module('somename').
config(function($stateProvider, $urlRouterProvider) {
$stateProvider.
/**
* Login Form State
**/
state('login', {
url: '/login',
templateUrl: 'views/login.tpl.html',
controller: 'loginCtrl',
authenticate: false,
bodyClass: 'login'
}).
/**
* Root View, Sees Widgets States
*/
state('logged-in', {
url: '/',
templateUrl: 'views/logged-in-root.tpl.html',
controller: 'rootCtrl',
authenticate: true,
bodyClass: 'home'
}).
/**
* The Search Form States
*/
state('logged-in.search', {
url: 'search',
authenticate: true,
bodyClass: 'search',
pageTitle: 'Search | Crowdskout',
views: {
'main@logged-in' : {
templateUrl: 'views/search/search.tpl.html',
controller: 'searchCtrl'
}
}
}).
/**
* List of Results States
*/
state('logged-in.results', {
url: 'results',
authenticate: true,
bodyClass: 'results',
pageTitle: 'Results | Crowdskout',
views: {
'main@logged-in' : {
templateUrl: 'views/results/results.tpl.html',
controller: 'resultsCtrl'
}
}
}).
/**
* Viewing All Profiles States
*/
// List of all profiles without specific selected
state('logged-in.result-all', {
url: 'result',
authenticate: true,
bodyClass: 'result',
pageTitle: 'Result | Crowdskout',
views: {
'main@logged-in' : {
templateUrl: 'views/result/result.tpl.html',
controller: 'resultCtrl'
}
}
}).
// Adding a new profile
state('logged-in.result-all.new-profile', {
url: '/profile/new',
authenticate: true,
bodyClass: 'new-profile',
pageTitle: 'New Profile | Crowdskout',
templateUrl: 'views/result/new-profile.tpl.html',
controller: 'newProfileCtrl'
}).
// Specific profile selected
state('logged-in.result-all.profile', {
url: '/profile/:profileId',
authenticate: true,
bodyClass: 'profile',
pageTitle: 'Profile | Crowdskout',
templateUrl: 'views/result/profile.tpl.html',
controller: 'profileCtrl'
}).
/**
* Viewing a Specific Result Set States
*/
// List of all the matching profiles without a specific profile selected
state('logged-in.result', {
url: 'result/:resultId',
authenticate: true,
bodyClass: 'result',
pageTitle: 'Result | Crowdskout',
views: {
'main@logged-in' : {
templateUrl: 'views/result/result.tpl.html',
controller: 'resultCtrl'
}
}
}).
// Adding a new profile while viewing a specific result set
state('logged-in.result.new-profile', {
url: '/profile/new',
authenticate: true,
bodyClass: 'new-profile',
pageTitle: 'New Profile | Crowdskout',
templateUrl: 'views/result/new-profile.tpl.html',
controller: 'newProfileCtrl'
}).
// Viewing a specific profile within a result set
state('logged-in.result.profile', {
url: '/profile/:profileId',
authenticate: true,
bodyClass: 'profile',
pageTitle: 'Profile | Crowdskout',
templateUrl: 'views/result/profile.tpl.html',
controller: 'profileCtrl'
}).
/**
* Taking Action on a Specific Result Set
**/
state('logged-in.actions', {
url: 'result/:resultId/action',
authenticate: true,
bodyClass: 'actions',
pageTitle: 'Take Action | Crowdskout',
views: {
'main@logged-in' : {
templateUrl: 'views/actions/action.tpl.html',
controller: 'actionCtrl'
}
}
}).
// Exporting to File
state('logged-in.actions.export', {
url: '/export',
authenticate: true,
bodyClass: 'actions export',
pageTitle: 'Export List | Crowdskout',
views: {
'modal@logged-in' : {
templateUrl: 'views/actions/export.tpl.html',
controller: 'exportCtrl'
}
}
}).
// Email list
state('logged-in.actions.email', {
url: '/email',
authenticate: true,
bodyClass: 'actions email',
pageTitle: 'Email List | Crowdskout',
views: {
'modal@logged-in' : {
templateUrl: 'views/actions/email.tpl.html',
controller: 'emailCtrl'
}
}
}).
/**
* States for viewing and managing user accounts
**/
// View all accounts
state('logged-in.accounts', {
url: 'accounts',
authenticate: true,
bodyClass: 'accounts',
pageTitle: 'Accounts | Crowdskout',
views: {
'main@logged-in' : {
templateUrl: 'views/account/accounts.tpl.html',
controller: 'accountsCtrl'
}
}
}).
// Create new account
state('logged-in.new-account', {
url: 'account/new',
authenticate: true,
bodyClass: 'new-account',
pageTitle: 'New Account | Crowdskout',
views: {
'main@logged-in' : {
templateUrl: 'views/account/new-account.tpl.html',
controller: 'newAccountCtrl'
}
}
}).
// View a specific account
state('logged-in.account', {
url: 'account/:accountId',
authenticate: true,
bodyClass: 'account',
pageTitle: 'Account | Crowdskout',
views: {
'main@logged-in' : {
templateUrl: 'views/account/account.tpl.html',
controller: 'accountCtrl'
}
}
}).
/**
* States for viewing and managing outside connections
**/
state('logged-in.connect', {
url: 'connect',
authenticate: true,
bodyClass: 'connect',
pageTitle: 'Connect | Crowdskout',
views: {
'main@logged-in' : {
templateUrl: 'views/connect/index.tpl.html'
}
}
}).
// View and update Mailchimp accounts
state('logged-in.connect.mailchimp', {
url: '/mailchimp',
authenticate: true,
bodyClass: 'connect mailchimp',
pageTitle: 'Mailchimp | Crowdskout',
views: {
'main@logged-in' : {
templateUrl: 'views/connect/mailchimp.tpl.html'
}
}
}).
state('logged-in.connect.import', {
url: '/import',
authenticate: true,
bodyClass : 'connect import',
pageTitle: 'Import List | Crowdskout',
views: {
'main@logged-in' : {
templateUrl: 'views/connect/import.tpl.html'
}
}
}).
state('logged-in.client', {
url: '/client',
authenticate: true,
bodyClass : 'client',
views: {
'main@logged-in' : {
templateUrl:'views/client/index.tpl.html'
}
}
});
$urlRouterProvider.otherwise('/login');
});
最后一个网址客户端还没有出现。它重定向到登录。 感谢
答案 0 :(得分:1)
如果您尝试使用类似baseUrl / asdfasd的网址,则会将您带到/ login,并在此处写入:
$urlRouterProvider.otherwise('/login');
看看你的链接是否
ui-sref="logged-in.client"
也可以尝试使用'client'而不是'/ client'
如果没有更多代码,我们就无法说出任何其他内容。
答案 1 :(得分:1)
尝试更改最后一条路线的url属性以消除额外的斜线。
state('logged-in.client', {
url: 'client',
authenticate: true,
bodyClass : 'client',
views: {
'main@logged-in' : {
templateUrl:'views/client/index.tpl.html'
}
}
})