I have a form which accepts an input and that input will be used by my API to retrieve the data. As per angular, I can use @input or Behavioural subject for sharing this value with child components or unrelated components.
Since my input will be one time activity, why cant I use a service with a private variable to share it with different components rather than using @input and Behavioural subject ?
What I'm saying is:
In the template:
<html>
<body>
EmployeeID <input type="text">
<button type="submit" (click) ="onsubmit()>Submit</button>
</body>
</html>
In component:
onsubmit() {
this.myservice.addData(inputValue)
}
And in the service:
private myinput
addData(input){
this.myinput.add(input)
}
And this is jus a rough code and not actual one..