我是 Angular 新手,我真的需要帮助,并提前致谢
constructor(private http: Http, private authService: AuthService, private router: Router) {
this.token = localStorage.getItem('token');
if(token){
this.interval = setInterval(this.ingameee, 5000);
}
}
ingameee() {
this.http.get('http://url.com/api/matchmaking/keepalive?token='+ this.token)
.subscribe(
response => {
this.dataa = response;
this.mod = this.dataa.json().mod;
this.playersinqueue = this.dataa.json().playersinqueue;
this.region_id = this.dataa.json().region_id;
this.party_id = this.dataa.json().party_id;
},
error => console.log(error),
);
}Run Code Online (Sandbox Code Playgroud)
我想从组件中显示一个模态.我有一个使用ng-bootstrap创建的模态组件,如follow(只是一个正文):
<template id="accept" #content let-c="close" let-d="dismiss">
<div class="modal-body">
<p>Modal body</p>
</div>
</template>
import { Component } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'my-hello-home-modal',
templateUrl: './hellohome.modal.html'
})
export class HelloHomeModalComponent {
closeResult: string;
constructor(private modal: NgbModal) {}
open(content) {
this.modal.open(content).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
console.log(reason);
});
}
}
Run Code Online (Sandbox Code Playgroud)
我真的希望能够从组件中打开这个模态
看我的homeComponent
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'my-home',
templateUrl: './home.component.html'
})
export class HomeComponent implements OnInit {
constructor() …Run Code Online (Sandbox Code Playgroud)