admin管理员组文章数量:1387303
I have a dynamic route defined as:
$urlRouterProvider
.when(
'/:resource?collection&type&id',
[
'$match', '$stateParams',
function routeValidator( $match , $stateParams )
{
var path = '';
angular.forEach($match, function joinner( val , key )
{
if ( angular.isDefined(val) ) path += '/' + val;
});
return path;
}
]
)
.when( '' , '/about' )
.when( '/' , '/about' )
.otherwise( '/404' );
And then several states:
$stateProvider
.state('about',
{
"url": "/about",
"templateUrl": "about.tmpl"
}
)
//…
I try hitting index.html#/
or index.html#/about
, and none of my states are getting invoked (and subsequently none of my controllers). BUT my routes are obeyed (ex '' gets redirected to '/about'). No console errors and values return as expected (ex. for index.html#/about
, $match & path = /about
).
Edit
It seems Require is part of the issue:
- Here it's working in jsfiddle without require.
- Here it's not working in plunker with require.
I have a dynamic route defined as:
$urlRouterProvider
.when(
'/:resource?collection&type&id',
[
'$match', '$stateParams',
function routeValidator( $match , $stateParams )
{
var path = '';
angular.forEach($match, function joinner( val , key )
{
if ( angular.isDefined(val) ) path += '/' + val;
});
return path;
}
]
)
.when( '' , '/about' )
.when( '/' , '/about' )
.otherwise( '/404' );
And then several states:
$stateProvider
.state('about',
{
"url": "/about",
"templateUrl": "about.tmpl"
}
)
//…
I try hitting index.html#/
or index.html#/about
, and none of my states are getting invoked (and subsequently none of my controllers). BUT my routes are obeyed (ex '' gets redirected to '/about'). No console errors and values return as expected (ex. for index.html#/about
, $match & path = /about
).
Edit
It seems Require is part of the issue:
- Here it's working in jsfiddle without require.
- Here it's not working in plunker with require.
-
The first thought is how about using
$locationProvider.hashPrefix('!');
and link asindex.html!#/about
Algularjs sometime has a mess with hashtags – IgorCh Commented Dec 4, 2013 at 9:28 -
Just tried that. Nothin' :/ Sidenote: hashPrefix('!') prepends to the route after the # symbol:
index.html#!/about
– Jakob Jingleheimer Commented Dec 4, 2013 at 19:27
1 Answer
Reset to default 9Turn's out I'm an idiot: When I switched from ngRouter to ui.router, I forgot to switch ng-view
to ui-view
. Working plunkr: http://plnkr.co/edit/ZckIBlayuB10hooJ0sY5
本文标签: javascriptangularui uirouter dynamic routes and statesStack Overflow
版权声明:本文标题:javascript - angular-ui: ui-router dynamic routes and states - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744492508a2608820.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论