小编has*_*van的帖子

错误类型错误:无法读取未定义的属性“get”

在此处输入图片说明错误类型错误:无法读取未定义的属性“get”

我是 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)

typescript angular

6
推荐指数
1
解决办法
2万
查看次数

如何从组件中打开模态

我想从组件中显示一个模态.我有一个使用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)

ng-bootstrap angular

4
推荐指数
2
解决办法
9043
查看次数

标签 统计

angular ×2

ng-bootstrap ×1

typescript ×1