【问题标题】:Read post data in angular 2以角度2读取帖子数据
【发布时间】:2017-07-19 07:27:00
【问题描述】:

我是 Web 开发的新手,也许我要解决的问题是一个非常基本的问题,但我在 Google 上搜索了很多,但找不到解决方案。 我有两个网页onetwo

下面是one.html

<form id="requestForm" #requestForm ngNoForm action="{{requestUrl}}" method="POST">
<div *ngIf="requestmodel">
    <button class="btn-flat waves-effect waves-light transparent regNrmS2BN" type="submit" id="submitForm" style="color: transparent; background-color: transparent;">Pay</button>
    <input type="hidden" name="name" [ngModel]="requestmodel.name" />
</div>
</form>

上面的表格会自动发布到下一个网页two.html,下面是用ComponentOne编写的代码

ngOnInit(): void {
    this.requestmodel = this.requestService.getRequest();
    this.requestUrl = 'http://localhost:3000/two';
    this.submitMe();
}

submitMe() {
    let me = this;
    if ($('#submitForm') && $('#submitForm')[0])
        $('#submitForm')[0].click();
    else
        setTimeout(function () { me.submitMe(); }, 100);
}

问题是我如何读取ComponentTwo 中的表单数据,并且要求我不应该使用Service,否则根本不会有任何问题。 那么,如果没有服务类,我怎么能做到这一点呢?

【问题讨论】:

    标签: javascript html angularjs node.js post


    【解决方案1】:

    您可能必须使用 EventEmitter 和 @Output 才能在外部访问此事件。然后在另一个 html 文件中将其用作事件,并将变量作为 $event 传递给您的打字稿文件。

    希望我的问题没有误导你

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-20
      • 1970-01-01
      相关资源
      最近更新 更多