ก่อนอื่นต้องถามก่อนครับ ว่าเรียกใช้ component ยังไง เพราะเท่าที่ดูแล้วไม่ว่าจะส่งค่าอะไรไปมันก็เป็น true นะครับเช่น
app.component.ts (TS)
import {Component, Input} from '@angular/core'; @Component({ selector: 'app-story-form', template: ` <h3>Favorite: {{mark}}</h3> ` }) export class StoryComponent { public favorite = false; @Input('mark') set mark(mark) { this.favorite = true; } get mark(): boolean { return this.favorite; } }
story.component.ts (TS)
import {Component} from '@angular/core'; @Component({ selector: 'app-root', template: ` <app-story-form [mark]="appMark"></app-story-form> ` }) export class AppComponent { appMark: string; }
Result: ยังไงก็เป็น true ครับ
bamossza
พลังงานการช่วยเหลือ
( Level 3 )
คะแนนขอบคุณจากสมาชิก
( 16 )
ตอบกระทู้ ( 112 )
เขียนบทความ ( 28 )
ก่อนอื่นต้องถามก่อนครับ ว่าเรียกใช้ component ยังไง เพราะเท่าที่ดูแล้วไม่ว่าจะส่งค่าอะไรไปมันก็เป็น true นะครับ
เช่น
app.component.ts (TS)
story.component.ts (TS)
Result: ยังไงก็เป็น true ครับ