angular.js - How to add parameters to templateUrl in angularjs routing?
伊谢尔伦
伊谢尔伦 2017-05-15 16:50:33
0
1
643
app.config(function($routeProvider)
{
$routeProvider.when('/project/:id',{
    templateUrl: 'project',
    controller:'projectController'
});});

I want to pass the id to templateUrl, which means that the actual access is 'project/id'. Is there a way to do it? Because at this time, a request is made to the background action based on the ID. Novice please give me advice.

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学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