I am looking to explore a new method of passing data using providers directly within the component itself. For instance, I am curious if there is a way to pass a variable from one component to another without relying on routing or other traditional methods.
Is it possible for the variable to be dynamic rather than static when passed between components? I prefer not to have the variable be static.
one.component.ts
public dynamicVariable:string = 'pass this data to two component'
two.component.ts
@component({
selector : 'app-two-component',
templateUrl: './two.component.html',
styleUrls: ['./two.component.css'],
provider: [Onecomponent] // inject OneComponent here
})
export class TwoComponent implements OnInit {
consructor() {}
ngOnInit() {
}
}