Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Services
- angular.module('myService', [])
- .service('myService', myService)
- function myService($http){
- const url = 'http://127.0.0.1/api/potatoes'
- const method = 'GET'
- $http({url, method})
- .success((data) => { return vm.potato = data })
- .error((err) => { return err })
- }
- --------------------------------------
- //Routes
- angular.module('myRoute', [])
- .config(bla bla bla)
- $routeProvider
- //routes here
- --------------------------------------
- //Controller
- angular.module('app', ['myService', 'myRoute'])
- .controller('myController', myController)
- function myController(){
- let vm = this;
- myService.foo()
- return vm.potato
- }
- myController.$inject = ['myService']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement