小编que*_*ons的帖子

如何在打字稿中将存储在 Observable<any> 中的值转换为字符串?

嗨,我是 Angular 和 TypeScript 的新手。我需要Observable一个字符串格式的值,如何做到这一点?

BmxComponent 文件

export class BmxComponent {
    asyncString = this.httpService.getDataBmx();
    currentStock = this.httpService.getDataBmx2(); //this is what I want to covert to a string so I can pass it to onSubmit()

    onSubmit() {
        const asnNumm = this.currentStock; // passing it here changes my database, see below
        this.httpService.sendData({ stock: asnNumm })
            .subscribe(
            data => console.log(data),
            error => console.log(error)
            );
    }
}
Run Code Online (Sandbox Code Playgroud)

HttpService 文件

export class HttpService {

    constructor(private http: Http) {}

    getDataBmx() {
        return this.http.get('https://the-bicycle-shop.firebaseio.com/products/Bicycles/bmx/stock.json')
            .map((response: …
Run Code Online (Sandbox Code Playgroud)

string json observable typescript angular

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

Opengl 3D 立方体无法在 Windows 上正确呈现

我正在学习有关 Udemy - Modern Opengl 3.0 的教程。我已成功进入基本教程第 5 部分“投影和坐标系”。这在具有相同代码的 Mac 上完美运行,但我无法在 Windows 上运行。我什至重新启动了本教程,以确保我没有遗漏任何内容,并且之前的所有教程都有效,但我得到了相同的结果。它只是不会正确渲染。我在 Windows 上的 Visual Studio 2015 上做了这个。在 mac 上,我通过使用 vim 和 Makefile 来使用它……您会认为使用为您编译的 IDE 会更容易,但显然不是。

渲染的立方体

这就是我的屏幕上显示的内容,只是它闪烁得非常快并且移动很多,而不是我应该得到的旋转立方体。

这是代码:

着色器.h:

#ifndef SHADER_H
#define SHADER_H

#include <string>
#include <fstream>
#include <sstream>
#include <iostream>

#include <GL/glew.h>

class Shader
{
public:
    GLuint Program;
    // Constructor generates the shader on the fly
    Shader(const GLchar *vertexPath, const GLchar *fragmentPath)
    {
        // 1. Retrieve the vertex/fragment source code from filePath
        std::string vertexCode;
        std::string fragmentCode;
        std::ifstream vShaderFile; …
Run Code Online (Sandbox Code Playgroud)

c++ opengl 3d glfw glm-math

0
推荐指数
1
解决办法
182
查看次数

标签 统计

3d ×1

angular ×1

c++ ×1

glfw ×1

glm-math ×1

json ×1

observable ×1

opengl ×1

string ×1

typescript ×1