'message = 'Hello ${name}' doesn't replace the name parameter in the message string immediately [closed]
I cannot make working the basic typescript feature that I see written everywhere over the Internet, that says that :
var a = "Bob"
var message = 'Hello ${a}'
would see a console.log(message) print "Hello Bob".
When I attempt this:
import { Component } from '@angular/core';
import { environment } from '../environments/environment';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'etude';
constructor() {
console.log('Démarrage environnement ' + environment.nom_environnement + ' spark: ' + environment.spark_url + ' backend: ' + environment.backend_url);
const a = 'Démarrage environnement ${environment.nom_environnement} spark: ${environment.spark_url} backend: ${environment.backend_url}';
console.log(a);
}
}
My console logs are showing that:
Démarrage environnement dev spark: http://localhost:9090 backend: http://localhost:9091 main.js:1:598971
Démarrage environnement ${environment.nom_environnement} spark: ${environment.spark_url} backend: ${environment.backend_url}
Whatever I try let a or var a instead of const a.
Reading over the Internet, the transformation should had happened immediately?
Solution 1:[1]
Use `` instead of ""
var a = "Bob"
var message = `Hello ${a}`
Solution 2:[2]
Before you use connect(), use
socket.bind((ipaddr, port))
to determine the source addr and source port. If addr or port is equal to '' or 0, it means using OS default.
Solution 3:[3]
Just set the host IP like @Jalo said connect(('179.XX.XX.XX', 5005)), the system will choose wich interface needs to use to interact with that host.
If you need more info to understand how just read Routing in Linux
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Enam Kyei |
| Solution 2 | BusyProgrammer |
| Solution 3 | Raskayu |
