在angularJS Routing中传递2个不同的参数,即Id和Name

时间:2017-11-09 13:07:54

标签: javascript jquery angularjs angularjs-routing angularjs-1.6

使用Angularjs中的路由在url中传递2参数。

即。我想网址就像/Business/Industry/3/Aviation

这是MVC控制器:

public ActionResult Industry(int ServicesId, string Servicesname = "")
        {
            return View();
        }

这是锚标记:

 <a href="#/Industry/{{list.Id}}/{{list.IndustryName}}">

注意:两者都是动态list.Id和list.IndustryName

这是角度路由:

我试过以下但不正确。

任何人都可以告诉我该怎么做。 如何通过路由呼叫。

.when('/Business/Industry/:Id', { templateUrl: '/Business/Industry', controller: 'BusinessIndustry' });

1 个答案:

答案 0 :(得分:0)

你快到了:

.when('/view2/:pqid/:cid'

以这种格式映射到网址:

view2/1234/4567

1234是pqid,4567是cid。

所以你的路由,我认为是有效的,只需将链接更改为#/ view2 / 775/4。

或者,如果您想保留相同的链接,请将路由更改为:

#/view2/pqid/:pqid/cid/:cid