Skip to content

Instantly share code, notes, and snippets.

@fannyhasbi
Last active October 27, 2018 02:40
Show Gist options
  • Save fannyhasbi/02e772c6b113ae6f860ab15433c203c3 to your computer and use it in GitHub Desktop.
Save fannyhasbi/02e772c6b113ae6f860ab15433c203c3 to your computer and use it in GitHub Desktop.
Vue instance for PWA
new Vue({
el:'#app',
data:{
kodepos : [],search : '', awal:0,akhir:10,halaman:1,tampil:true
},
created(){
this.getData();
console.log(this.awal)
},
methods:{
next(){
this.awal=this.awal+=10
this.akhir=this.akhir+=10
this.halaman=this.halaman+=1
},
prev(){
this.awal=this.awal-=10
this.akhir=this.akhir-=10
this.halaman=this.halaman-=1
},
getData(){
var kd=this;
axios.get('https://kodepos-2d475.firebaseio.com/kota_kab/k110.json?print=pretty').then(function(response){
kd.kodepos=response.data;
})
}
},
computed:{
cari(){
return this.kodepos.filter(pos =>{
return pos.kecamatan.toLowerCase().match(this.search.toLowerCase());
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment