[英]How can i see the result form my typeScript in the HTML?
This is my HTML这是我的 HTML
*i changed all the code *我更改了所有代码
<div class="testCenter">
<h1>{{teston()}}</h1>
</div>
This is my .ts code the function teston() i dont know if it make sense这是我的 .ts 代码函数 teston() 我不知道它是否有意义
import { Component, OnInit } from '@angular/core';
import { Carte } from '../mesClass/Carte'; // importation de la class Carte
@Component({
selector: 'app-gestion-poker',
templateUrl: './gestion-poker.component.html',
styleUrls: ['./gestion-poker.component.css']
})
export class GestionPokerComponent implements OnInit {
test:Carte;
constructor() { }
ngOnInit(): void {
}
teston(){
return this.test.carte(1);
}
}
This is my class Carte.ts这是我的课 Carte.ts
export class Carte {
// Attributs
sorte = new Array;
carte(sor){
this.sorte = sor;
sor = ["hello","Bob"];
}
}
So what i want to do is to see in my HTML: Bob所以我想要做的是在我的 HTML 中看到: Bob
nothing seems to work am i missing something?似乎没有任何效果我错过了什么吗?
I think:我认为:
Depending on your code, i think you want somethink like this:根据您的代码,我认为您想要这样的想法:
export class Carte {
sorte: Array<string> = ['hello', 'Bob'];
carte(sor){
return this.sorte[sor]
}
}
And in your ts file something like this:在你的 ts 文件中是这样的:
import { Component, OnInit } from '@angular/core';
import { Carte } from '../mesClass/Carte'; // importation de la class Carte
@Component({
selector: 'app-gestion-poker',
templateUrl: './gestion-poker.component.html',
styleUrls: ['./gestion-poker.component.css']
})
export class GestionPokerComponent implements OnInit {
test:Carte;
constructor() { }
ngOnInit(): void {
this.test = new Carte();
}
teston(){
return this.test.carte(1);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.