Dynamically constructed ui-sref attribute in ui-router

前端 未结 2 1083
萌比男神i
萌比男神i 2020-12-09 04:52

I am new to angular and especially ui-router.

Here is a link:

SomeText

The link

2条回答
  •  遥遥无期
    2020-12-09 05:25

    You are almost there. Just the parameter must be part of the URL definition, not the name of the state:

    .state('topics',{
        url: '/{id:[0-9]{1,8}}', // we can also add some constraint, like int id only
        templateUrl: "",
        controller: ""
     })
    

    And how to call it (where currentItem.id would be injected dynamically as a part of some ng-repeat)

    SomeText
    

    Because ui-sref means: ui-sref='stateName({param: value, param: value}). More info here:

    • ui router, URL Parameters
    • ui-sref

提交回复
热议问题