angular : ui-router 操作原理

时间:2023-03-09 03:04:38
angular : ui-router 操作原理
<body>
<a ui-sref="title">title<a>
</body>

ui-router 会去解析body里的ui-sref,title对ui-router来说是一种状态,接着会去找着状态

$stateProvider
.state('title', {
url: '/title',
...
})

state就是状态,发现了就会把

<a ui-sref="title">title<a>

换成正常的href="title"


路径:www.example.com

首先去when找,找到redirect

没有去state找,找到就走

没有去otherwise,再去when

        $urlRouterProvider.
when("/", "/home").
otherwise("/");

×所有的状态头可以是参数

23-OCT-2015

<a ui-sref="{{$state.current.name}}(stateParam)">GO</a>

在searhing 时可以注入stateParam这对象。