How to instantiate Angular components with parameters?
问题 I've been trying to instantiate components by passing parameters like nameFilter = new FilterComponent("Name"); but I'm getting this error: NullInjectorError: No provider for String! I believe dependency injection causes this as I don't get any errors if I don't inject anything to component. So what exactly causes this and how can I fix it? Here's the component code import { Component, OnInit, Inject } from '@angular/core'; @Component({ selector: 'app-filter', templateUrl: './filter.component