@ Html.ActionLink和Angularjs价值? [英] @Html.ActionLink and Angularjs value?

查看:175
本文介绍了@ Html.ActionLink和Angularjs价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我现在干活就已经实现angularjs一个项目,我想知道如果有周围方式HTML辅助使用角度值?

Hey i'm currently workin on a project that has implemented angularjs, i was wondering if there is a way around to use angular value in Html Helper?

这就是我不能去工作:

@Html.ActionLink("Edit", "Edit", new { id = {{row.Id}} })

如何在剃刀语法使用值?

How do you use the value in razor syntax?

推荐答案

使用问题 ActionLink的的是,这种方法调用 UrlPathEn $ C $ ç创建网址的时候。这意味着是剃刀指令 {{}} 使用get EN codeD。角将无法评估它。你将要做的就是单独创建这个URL,然后去code吧。例如,我有一些像在页面中为我们的项目之一。

The problem with using ActionLink is that this method calls UrlPathEncode when creating URL. What this means is that razor directive {{}} with get encoded. Angular will not be able to evaluate it. What you will have to do is create this URL separately and then decode it. For example I have something like in one of the pages for our project.

@{
var url = Url.Action("Index", "Home", new{id="{{id=lastLatency}}"});
url = HttpUtility.UrlDecode(url);
}

<a data-ng-href="@url">Home</a>

这是非常重要的,你用 NG-HREF 属性来设置URL。

这篇关于@ Html.ActionLink和Angularjs价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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