Advertisement
randomCodes

Untitled

Sep 16th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Services
  2. angular.module('myService', [])
  3. .service('myService', myService)
  4.  
  5. function myService($http){
  6.     const url = 'http://127.0.0.1/api/potatoes'
  7.     const method = 'GET'
  8.    
  9. $http({url, method})
  10. .success((data) => { return vm.potato = data })
  11. .error((err) => { return err })
  12.    
  13. }
  14. --------------------------------------
  15. //Routes
  16. angular.module('myRoute', [])
  17.     .config(bla bla bla)
  18.     $routeProvider
  19.         //routes here
  20. --------------------------------------
  21. //Controller
  22. angular.module('app', ['myService', 'myRoute'])
  23.     .controller('myController', myController)
  24.  
  25. function myController(){
  26.     let vm = this;
  27.     myService.foo()
  28.         return vm.potato
  29. }
  30.  
  31. myController.$inject = ['myService']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement