3
pagemethod可以工作,但是當我使用webmethod時,它會刷新頁面,摧毀首先使用角2的原因。如何在aspx中停止角2中的頁面刷新
如何防止表單刷新頁面?
的Index.aspx
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManagerMain"
runat="server"
EnablePageMethods="true" >
</asp:ScriptManager>
<my-app>Loading...</my-app>
</form>
</body>
index.aspx.cs
[WebMethod]
public static string getString()
{
return "Test";
}
app.component.html
<div>
<Button (click)="btnSubmit_Click">test</Button>
</div>
app.component.ts
btnSubmit_Click()
{
var test = window['PageMethods'].getString(this.onSucces, this.onError);
}
說明:
在這一刻,我試圖使用角2與公司的aspx公司,如果它的作品可能會成爲小前端api的標準,因爲它的信息相當有限,我感謝任何幫助。