尝试在子视图之间切换,但是当另一个孩子已经加载时,ui-sref会生成一个错误的URL。 正确的链接:'template / viewname.html' 实际链接:'home / template / viewname.html' 如何阻止ui-sref在链接中添加“home /”? 感谢
app
angular.module('app',[,'ngRoute','ui.router']);
配置
angular.module('app').config(['$urlRouterProvider', '$stateProvider', '$locationProvider', function ($urlRouterProvider, $stateProvider, $locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
$urlRouterProvider.otherwise('/');
$stateProvider.state('home', {
url: '/home',
templateUrl: 'template/index.html',
controller: 'contr'
})
.state('home.about', {
parent:'home',
url: '/about',
templateUrl: 'template/about.html',
controller: 'contr'
})
.state('home.contact', {
parent: 'home',
url: '/contact',
templateUrl: 'template/contact.html',
controller: 'contr'
}) }]);
主页
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
</head>
<body>
<h3>Home</h3>
<div>
<a ui-sref="home.about">abouttt</a>
<a ui-sref="home.contact">contact</a>
</div>
<div ui-view>
</div>
</body>
</html>
答案 0 :(得分:2)
你在脚下射击自己:
有关详细信息,请参阅https://docs.angularjs.org/guide/ $ location#relative-links。
答案 1 :(得分:0)
我建议您在Program Main_Program
USE Mod_Example
INTERFACE
FUNCTION func(vector)
REAL, DIMENSION(:), INTENT(IN) :: vector
REAL :: func
END FUNCTION func
FUNCTION dfunc(vector)
REAL, DIMENSION(:), INTENT(IN) :: vector
REAL, DIMENSION(size(vector)) :: dfunc
END FUNCTION dfunc
END INTERFACE
! do stuff
! calls test_routine form module
! uses dfunc and func defined below
call test_routine(res,start,fin,vector,func,dfunc)
! do stuff
END PROGRAM Main_Program
! define dfunc and nfunc for passing into the modular subroutine
FUNCTION func(vector)
IMPLICIT NONE
REAL, DIMENSION(:), INTENT(IN) :: vector
REAL :: func
nfunc = vector
END FUNCTION func
FUNCTION dfunc(vector)
IMPLICIT NONE
REAL, DIMENSION(:), INTENT(IN) :: vector
REAL, DIMENSION(size(vector)) :: dfunc
dfunc = vector
END FUNCTION dfunc
中使用绝对网址,即使用前导斜杠。例如:
templateUrl
答案 2 :(得分:0)
只是一个小小的问题:http://plnkr.co/edit/RbjGt8zhAGSRb00idkEU?p=preview
var app = angular.module('plunker', ['ui.router'])
.config(['$stateProvider', '$urlRouterProvider','$locationProvider', function($stateProvider, $urlRouterProvider, $locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
})
$stateProvider.state('home', {
url: '/home',
})
.state('home.about', {
parent:'home',
url: '/about',
views:{
'@':{
'templateUrl': '/tpl1.html'
}
}
//controller: 'contr'
})