I 'm having a problem setting an Input property. What I'm trying to do is pass a value from app.component.ts called passBool and set the property of the nextComponent called receivedBool.
Here are my codes:
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<nextComponent [receivedBool]="passBool"></nextComponent>
`
})
export class AppComponent {
//Variables
passBool: Boolean = true;
constructor(){
console.log('The boolean value we are trying to pass is: ' + this.passBool)
}
}
nextComponent.component.ts
import { Component, Input } from '@angular/core';
@Component({
selector: 'nextComponent',
template: `<i> </i> `
})
export class NextComponent {
@Input() receivedBool: Boolean = false;
constructor () {
console.log('The boolen value we are receiving here is: ' + this.receivedBool)
}
}
Console log results are:
The boolean value we are trying to pass is: true
- app.component.ts
The boolean value we are receiving here is: false
- nextComponent.component.ts
I hope you could enlighten me. Thanks!