jac*_*cob 2 javascript requirejs angularjs angular-ui angular-ui-router
我有一个动态路由定义为:
$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' );
Run Code Online (Sandbox Code Playgroud)
然后是几个州:
$stateProvider
.state('about',
{
"url": "/about",
"templateUrl": "about.tmpl"
}
)
//…
Run Code Online (Sandbox Code Playgroud)
我尝试点击index.html#/或者index.html#/about,我的状态都没有被调用(后来没有我的控制器).但是我的路线被遵守(前''被重定向到'/ about').没有控制台错误和值按预期返回(例如index.html#/about,$ match&path = /about).
似乎需求是问题的一部分:
| 归档时间: |
|
| 查看次数: |
2978 次 |
| 最近记录: |