【发布时间】:2021-08-19 15:37:16
【问题描述】:
我在这个组件中有一个名为“CreateBugsViewComponent”的组件我想使用另一个组件“ProjectBugsComponent”的ngOnit功能我该怎么做?“CreateBugsViewComponent”的代码写在下面:
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { MatDialogRef } from '@angular/material/dialog';
import { MatSnackBar } from '@angular/material/snack-bar';
import { Router } from '@angular/router';
import { Subscription } from 'rxjs';
import { environment } from '../../environments/environment';
@Component({
selector: 'app-createbugview',
templateUrl: './createbugview.component.html',
styleUrls: ['./createbugview.component.scss']
})
export class CreatebugviewComponent implements OnInit {
onbugsubmit(){
if(this.createbugform.valid)
{
this.createbugform.controls['BugsAttachments'].setValue(this.images);
this.http.post(this.baseURI+'Bugs/Addbug',this.createbugform.value).subscribe(
(data:any) => {
this.dialogRef.close();
//this.changeLocation(),
this.snackbar.open(data.message,'✖', {
duration:4000,
horizontalPosition:'center',
verticalPosition:'top'
}),
//this.dialog.closeAll(),
localStorage.removeItem('ProjectId')/////////////////In this function I want to use ngOnit of ProjectBugsComponent Component.
}
)
}
}
如果有任何其他人想要的信息,请在我将为您提供的 cmets 中告诉我。
【问题讨论】:
标签: angular angular-material angular-components ngoninit