我从服务器获取数据,将其传递到一个变量,然后再次转到它以将其添加到url中,但它始终提供它-undefined,但是当此变量显示在app.html中时,一切将正确显示
{{nodesID}} //好结果= 15
component.ts
nodesID: any; //tried - number and string
public url = 'http://localhost:8080/nodesID'; // undefined, should be 15
this.serviceNodes.getCleitnId(Tokenstorageservice.myUsername())
.subscribe(result => this.nodesID = result);
谢谢
从服务器获取数据后,将值分配给变量。
nodesID: any; //tried - number and string
public url = ''; // don't assign the nodesID at this point
this.serviceNodes.getCleitnId(Tokenstorageservice.myUsername())
.subscribe(result => {
this.nodesID = result
this.url = 'http://localhost:8080' + '/' + this.nodesID;
});