I am attempting to streamline my application by using a single template to reference a custom element, and then specify the contents via the @Input() property decorator. The method I am using isn't working and I'm not sure why, my code is as follows:
Component.ts
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'side-menu-option',
templateUrl: './side-menu-option.component.html',
styleUrls: ['./side-menu-option.component.css']
})
export class SideMenuOptionComponent implements OnInit {
@Input() icon: string; // Inputs
@Input() text: string;
constructor() { }
ngOnInit() {
}
}
Component.html
<button class="buttons button-style btn-block" type="button"><i class="mdi mdi-{{icon}}"></i><span class="menu-text">{{text}}</span></button>
OtherComponent.html
<div class="side-nav text-center">
<div class="side-nav-container">
<img class="avatar" src="http://placehold.it/150x150">
<side-menu-option [icon]="home" [text]="Home"></side-menu-option>
<side-menu-option [icon]="file-document" [text]="Documents"></side-menu-option>
</div>
</div>
[icon] and [text] are not being recognized for some reason and I am not sure why. It worked before I tried to refactor it, but for some reason these inputs are not being loaded.
Thanks