angular.js - angularjs 路由中的templateUrl如何加参数?
伊谢尔伦
伊谢尔伦 2017-05-15 16:50:33
0
1
625
app.config(function($routeProvider)
{
$routeProvider.when('/project/:id',{
    templateUrl: 'project',
    controller:'projectController'
});});

我想把id传到templateUrl中,就是实际访问的是'project/id',有办法做到吗?因为此时是根据id向后台的action发请求。新手求指教。

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
PHPzhong

Okay, I just looked at the API and tested it. It can be written directly as a function.

app.config(function($routeProvider)
{
$routeProvider.when('/project/:id',{
    templateUrl: function($routeParams){return 'project/'+$routeParams.id;},
    controller:'projectController'
});});
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template