Whatever values are inside the individuals are printed without issues but whatever is obtained using @Input or @Output is not displayed.
child.component.ts
JavaScript
x
19
19
1
@Component({
2
selector: 'app-form-input',
3
templateUrl: './form-input.component.html',
4
styleUrls: ['./form-input.component.scss']
5
})
6
7
export class FormInputComponent implements OnInit {
8
@Input() fieldType: string;
9
//with another Input and 1 Output DOM
10
11
constructor(
12
) {
13
}
14
15
ngOnInit() {
16
console.log(this.fieldType);
17
}
18
}
19
parent.component.html
JavaScript
1
5
1
<app-form-input (value)="action($event)"
2
[fieldType]="date"
3
[maxAllowItem]="1">
4
</app-form-input>
5
Is there anything goes wrong in syntax? The Log always show ‘undefined’ in all cases.
Thanks
Advertisement
Answer
I think this is trying to pull in a variable defined within your component.
Try the following syntax, wrap the string again, this should ensure you are passing a string and not a variable from the component, the input will then know to expect a string.
JavaScript
1
2
1
[fieldType]="'date'"
2
This is wrapping the string in "
and '
.