在我的应用程序中,ui-sref正在部分工作。对于某些链接来说,它是在生成href,而对于其他链接则不是。以下是我的代码:-
//对于ng-重复它不是有效的,但是对于其他人它是有效的。
<nav class="site-links" ng-controller="itemsController">
<ul class="nav-links">
<li ng-repeat="item in items">
<a ui-sref="{{item.link}}">
<span>{{item.Description}}</span>
</a>
</li>
<li><a ui-sref="index">Home</a></li>
<li><a ui-sref="route1">Route 1</a></li>
<li><a ui-sref="route2">Route 2</a></li>
</ul>
你能看看吗?
发布于 2015-11-09 09:59:06
如果您在路由器中定义了以下路由:
$stateProvider
.state( 'testState', {
url: '/test',
templateUrl: 'app/templates/test.html',
controller: 'testController'
});您可以通过ui-sref指令链接到此状态,只需使用它的名称。因此,以下内容是有效的:
<a ui-sref="testState">Something</a>
<a href="/test">Something</a> <!-- Notice the difference. Here we're using the reference to the route. -->因此,对于ui-sref,您需要告诉它状态的名称和普通的href,一个简单的路径是可以的。
https://stackoverflow.com/questions/33606451
复制相似问题