|
|
От: |
Serginio1
|
https://habrahabr.ru/users/serginio1/topics/ |
| Дата: | 18.03.17 11:07 | ||
| Оценка: | |||
class User {
num id;
string name;
User(this.id, this.name);
string getInfo() {
return "id: $id name: $name";
}
}class User {
constructor(public id:number, private name:string);
string getInfo() {
return `id: ${this.id} name: ${this.name}`;
}
}You can also use template strings, which can span multiple lines and have embedded expressions. These strings are surrounded by the backtick/backquote (`) character, and embedded expressions are of the form ${ expr }.
let fullName: string = `Bob Bobbington`;
let age: number = 37;
let sentence: string = `Hello, my name is ${ fullName }.
I'll be ${ age + 1 } years old next month.`