Dependency
To use the functionality from one module inside another module.
- Create your first module
- Add your module inside your second module inside ['first_module']
- If you did your first module in another file then import your file in your html
- <script src="product.js"/>
Service
Give functionality like:
- Fetching JSON data from a web service with $http
- Logging messages to JS console with $log
- Filtering an array with $filter
- All built-in Services start with dollar sign $
Service $http
Make an async request to a server
- $http( { method: 'GET' , url: '/products.json' } ) ;
- $http.get( '/products.json' , { apiKey: 'myApiKey' } ) ;
In both cases return a Promise object with .success() and .error()
- In this image appear how to declare the services in a Controller
Comentarios
Publicar un comentario