angularjs:如何从ASP.NET的页面,输入类型隐藏在价值? [英] angularjs : how to get a value from asp .net page with input type hidden?
本文介绍了angularjs:如何从ASP.NET的页面,输入类型隐藏在价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人是否知道如何做到这一点简单的事:从angularjs一个隐藏的输入字段获取值?用Google搜索了很多没有真正成功的C#在服务器端写一个产品ID,我需要找回它把它传递给我angularjs JSON服务。
Does someone know how to do this simple thing : get a value from a hidden input field with angularjs ? Googled a lot without real success... C# in server side writes a product id, and I need to retrieve it to pass it to my angularjs json service.
感谢名单上百万次,如果你能回答!
Thanx a million times if you're able to answer!
推荐答案
这是我如何做到这一点:
This is how I do it:
@functions{
public string GetAntiForgeryToken()
{
string cookieToken, formToken;
AntiForgery.GetTokens(null, out cookieToken, out formToken);
return cookieToken + ":" + formToken;
}
}
<input id="antiForgeryToken" type="hidden" value="@GetAntiForgeryToken()" />
var antiForgeryToken = $("#antiForgeryToken").val();
的 修改的
EDIT
如果没有jQuery的:
Without jQuery:
var antiForgeryToken = document.getElementById("antiForgeryToken").value;
使用角$文件:
var antiForgeryToken = $document.find("#antiForgeryToken").val();
这篇关于angularjs:如何从ASP.NET的页面,输入类型隐藏在价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文