Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Ngondestry在按钮单击后未激发_Javascript_Jquery_Asp.net_Angular_Typescript - Fatal编程技术网

Javascript Ngondestry在按钮单击后未激发

Javascript Ngondestry在按钮单击后未激发,javascript,jquery,asp.net,angular,typescript,Javascript,Jquery,Asp.net,Angular,Typescript,HTML <div class="form-group"> <button type="submit" value="submit" class="btn btn-secondary btn-float">Upload</button> </div>

HTML

<div class="form-group">
                  <button type="submit"

                          value="submit"
                          class="btn btn-secondary btn-float">Upload</button>
                </div>
              </div>

我正在尝试调用按钮上的服务,在从DOM中删除组件时,框架调用了我的Ngondestory(),我不知道它为什么不工作

在您的示例中,没有任何东西表明单击按钮会触发销毁

如果我有以下组件,单击按钮时将在子组件中调用
ngondestry


儿童触发器破坏

演示:

n销毁组件时将触发灾难。请检查挂钩。
export class testComponent implements  OnDestroy {

ngOnDestroy() {
    console.log("Fired ngOnDestroy");
  }

onClickSubmit() {

      this.subscription = this.service
        .create(test, url)
        .subscribe(
              res => {

                console.log('HTTP response', res)
              },
              err => {

                console.log("Error", err)
              },
              () => console.log('HTTP request completed.')
        );

  }
  }