Guest User

Untitled

a guest
Apr 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. const app = new Vue({
  2. el:'#app',
  3. data:{
  4. searchedLocation:'',
  5. loctionsResults:[]
  6. },
  7. watch:{
  8. searchedLocation:function(){
  9. this.getLocations();
  10. }
  11. },
  12. methods:{
  13. getLocations: _.debounce(function(){
  14. // Make a request to get list of locations
  15. axios.get('/getLocations/'+ this.searchedLocation)
  16. .then(function (response) {
  17. //console.log(response.data);
  18. this.loctionsResults = response.data;
  19. console.log(this.loctionsResults);
  20. })
  21. .catch(function (error) {
  22. console.log(error);
  23. });
  24.  
  25. },500)
  26.  
  27. },
  28.  
  29. });
  30.  
  31. <label for="location">Search by location</label>
  32. <input type="text" name="location" v-model='searchedLocation'>
  33. <ul>
  34. <li v-for = "item in loctionsResults">
  35. @{{item.location}}
  36. </li>
  37.  
  38.  
  39. </ul>
Add Comment
Please, Sign In to add comment