如何从角度组件html页面直接调用c#控制器操作
我需要直接从角度组件 html 页面调用 c#
控制器操作,无需打字稿文件。 如何编写控制器操作 Home/Subscribe
以直接从
action-xhr="/Home/Subscribe"
调用
<form method="post" class="subscription-form" action-xhr="/Home/Subscribe"
custom-validation-reporting="show-all-on-submit" target="_top" on="submit-error:submit-error.show">
<div class="subscription-form-fieldset">
<div class="subscription-form-div">
<label class="subscription-form-label">
<span class="subscription-form-span"></span>
<input on="tap:submit-error.hide" class="subscription-form-input" type="email" placeholder="Type your email..."
name="email" id="email" required>
<span visible-when-invalid="valueMissing" validation-for="email"></span>
<span visible-when-invalid="typeMismatch" validation-for="email">Please, enter a valid email address.</span>
</label>
</div>
<button class="subscription-form-submit" type="submit">
Subscribe
<div submitting class="subscription-form-submitting">
<i class="fa fa-spinner fa-spin"></i>
</div>
</button>
</div>
<div submit-error id="submit-error" class="subscription-form-submit-error">
<template type="amp-mustache">
{{subscribeSubmitErrorMessage}}
</template>
</div>
</form>
I need to call c#
controller action from angular component html page in directly without typescript file.
How I write a controller action Home/Subscribe
to directly call from
action-xhr="/Home/Subscribe"
<form method="post" class="subscription-form" action-xhr="/Home/Subscribe"
custom-validation-reporting="show-all-on-submit" target="_top" on="submit-error:submit-error.show">
<div class="subscription-form-fieldset">
<div class="subscription-form-div">
<label class="subscription-form-label">
<span class="subscription-form-span"></span>
<input on="tap:submit-error.hide" class="subscription-form-input" type="email" placeholder="Type your email..."
name="email" id="email" required>
<span visible-when-invalid="valueMissing" validation-for="email"></span>
<span visible-when-invalid="typeMismatch" validation-for="email">Please, enter a valid email address.</span>
</label>
</div>
<button class="subscription-form-submit" type="submit">
Subscribe
<div submitting class="subscription-form-submitting">
<i class="fa fa-spinner fa-spin"></i>
</div>
</button>
</div>
<div submit-error id="submit-error" class="subscription-form-submit-error">
<template type="amp-mustache">
{{subscribeSubmitErrorMessage}}
</template>
</div>
</form>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么要从 html 而不是从 ts 文件中执行?不建议这样做。大多数时候,您必须映射数据、处理错误,而您无法从 html 中做到这一点。
你应该重新考虑你的方法
Why do you want to do it from html and not from ts file? This is not recommended. Most of the time you have to map your data, handle the errors, and you can’t do that from your html.
You should reconsider your approach