Angularjs 使用mvc重定向页面时,ui sref不起作用
当我第一次呈现页面时,它将url显示为Angularjs 使用mvc重定向页面时,ui sref不起作用,angularjs,angular-ui-router,Angularjs,Angular Ui Router,当我第一次呈现页面时,它将url显示为http://localhost:18841/#/flight/Payment,当我点击链接(ui sref='flight.search')时,这个“/flight/Payment”出现 当我点击提交按钮时,我的payment.chstml页面是razor格式的,它重定向到付款操作方法,然后我的url变为http://localhost:18841/Flight/Payment#/之后,当我点击SearchButton时,它会像这样追加http://loc
http://localhost:18841/#/flight/Payment
,当我点击链接(ui sref='flight.search')时,这个“/flight/Payment”出现
当我点击提交按钮时,我的payment.chstml页面是razor格式的,它重定向到付款操作方法,然后我的url变为http://localhost:18841/Flight/Payment#/
之后,当我点击SearchButton时,它会像这样追加http://localhost:18841/Flight/Payment#/flight/search
和我的ui路由不工作,原因是什么?
这是我的$stateProvider
var appUrl = "";
if (!_.isUndefined(document.querySelector('#hdnCentraPath')) && !_.isNull(document.querySelector('#hdnCentraPath'))) {
appUrl = angular.element(document.querySelector('#hdnCentraPath'))[0].value;
}
$stateProvider
.state('home', { url: '/', templateUrl: appUrl + '/Flight/Welcome' })
.state('flight', { abstract: true, url: '/flight', templateUrl: appUrl+ '/Flight/Index' })
.state('flight.welcome', { url: '/', templateUrl: appUrl + '/Flight/Welcome' })
.state('flight.search', { url: '/search', templateUrl: appUrl + '/Flight/Search', controller: 'SearchCtrl' })
.state('flight.result', { url: '/result', templateUrl: appUrl + '/Flight/Result', controller: 'ResultCtrl' })
.state('flight.flightBooking', { url: '/FlightBooking', templateUrl: appUrl + '/Flight/FlightBooking', controller: 'FlightBookingCtrl' })
.state('flight.payment', { url: '/Payment', templateUrl: appUrl + '/Flight/PaymentDetails', controller: 'FlightBookingCtrl' })
.state('flight.cart', { url: '/cart', templateUrl: appUrl + '/Flight/Cart', controller: 'FlightCartCtrl' })
}您处于
飞行
状态,因此要路由到飞行/搜索
状态,您必须在状态提供程序中写入该url,不仅/search
共享相关代码,并尝试在plunker或fiddle上复制问题。共享您编写所有状态的代码模板URL编写的是什么?你有没有像这样把模板放在一个分层文件夹里?“http/'/'/someurl/Flight/Flightbook”?@mautrok我更新了问题,检查后我认为我发现了您的问题,但我仍然不理解您的appUrl+“”