如何从角度组件html页面直接调用c#控制器操作

发布于 2025-01-09 22:39:13 字数 1649 浏览 0 评论 0原文

我需要直接从角度组件 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云朵有点甜 2025-01-16 22:39:13

为什么要从 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文