我在angularjs中有html代码
<li ng-show="subCategory.status =='Active' || subCategory.status =='active'"
ng-repeat="subCategory in subCategories">
<a href="">
<strong ng-click="addDetails(subCategory)">
{{subCategory.subcategory}}
</strong>
</a>
<br>
</li>
subCategory in subCategories
与addDetails(subCategory)
函数内的网址相关联。
对于ng-repeat中的一个元素,我想链接到另一个单独的URL。 我怎样才能做到这一点?
答案 0 :(得分:2)
如果您使用ui-router
ui-sref=details({id:subCategory.subcategory})
配置中的
.state('details',{
url:'/details/:id',
templateUrl:'details.html'
得到它
myApp.controller('DetailController', ['$scope', '$stateParams', function($scope, $stateParams){
$scope.message = "Your ID is " + $stateParams.id;
或者如果你使用ngroute
myApp.controller('DetailController', ['$scope', '$routeParams', function($scope, $routeParams){
$scope.message = "Your ID is " + $routeParams.id;