Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const app = new Vue({
- el:'#app',
- data:{
- searchedLocation:'',
- loctionsResults:[]
- },
- watch:{
- searchedLocation:function(){
- this.getLocations();
- }
- },
- methods:{
- getLocations: _.debounce(function(){
- // Make a request to get list of locations
- axios.get('/getLocations/'+ this.searchedLocation)
- .then(function (response) {
- //console.log(response.data);
- this.loctionsResults = response.data;
- console.log(this.loctionsResults);
- })
- .catch(function (error) {
- console.log(error);
- });
- },500)
- },
- });
- <label for="location">Search by location</label>
- <input type="text" name="location" v-model='searchedLocation'>
- <ul>
- <li v-for = "item in loctionsResults">
- @{{item.location}}
- </li>
- </ul>
Add Comment
Please, Sign In to add comment