angularjs – 在ui-router中动态构造的ui-sref属性

我是新来的,特别是ui-router。

这是一个链接

<a ui-sref="/topic/{{topic.id}}">SomeText</a>

链接动态填充。

所以当我尝试从我的配置访问该状态,如下所示:

.state('topics/:topicId',{
        url:"",templateUrl: "",controller: ""
    })

我收到这个错误消息:

Error: Could not resolve ‘/topics/myTopic’ from state ‘topics’

在上面:myTopic是一个变量名。

你几乎在那里只有参数必须是URL定义的一部分,而不是状态的名称
.state('topics',{
    url: '/{id:[0-9]{1,8}}',// we can also add some constraint,like int id only
    templateUrl: "",controller: ""
 })

并且如何调用它(其中currentItem.id将被动态注入作为某些ng重复的一部分)

<a ui-sref="topics({id:currentItem.id})">SomeText</a>

因为ui-sref表示:ui-sref =’stateName({param:value,param:value})。更多信息:

> ui router,URL Parameters
> ui-sref

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...