Create a Service structure
- Write a custom Service
- Use the custom Service in Controller
Let's write our own service to do some basic math.
Using the existing directory structure, we've got a controller that's trying to call a service that doesn't exist yet, named
MathService. Create that service in
Our controller is trying to call
MathService.sum() with an array of numbers, expecting it to return the sum of all those numbers. Create this method, then see if it displays the sum correctly!