如何通过AngularJS中的templateUrl传递URL参数? [英] How to pass URL parameters through templateUrl in AngularJS?

查看:59
本文介绍了如何通过AngularJS中的templateUrl传递URL参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图学习AngulareJS陷入了困境.

Trying to learn AngulareJS got stuck with this.

这是代码:

app.config(function ($routeProvider){
$routeProvider
.when('/',
{       
    templateUrl: '/sort',
    controller : 'tasksController'      
})  
.when('/expression/:expressionId/type/:typeId',
{   
    templateUrl: '/sort/'+:expressionId +'/'+ :typeId,
    controller : 'tasksController'  
})});

这显然是错误的.

有人可以告诉我这样做的正确方法是什么吗?谢谢.

Can any one please tell me what is the correct way to do this? Thanks.

推荐答案

谢谢大家,这是我想要的

Thanks guys,this is what I wanted

.when('/expression/:expressionId/type/:typeId', {

templateUrl: function(params) {
    return '/sort/' + params.expressionId +'/'+ params.typeId ;
},
controller: 'tasksController'
});

这篇关于如何通过AngularJS中的templateUrl传递URL参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆