I'm working with laravel 5.5 and vuejs2 and lodash project. I want to skip first coming data in result like the image below. This is my vuejs2 code.
new Vue({
el:'#users',
data:{
message:'',
ok:false,
noresult:false,
arrayresults: [{id:'' ,username: '',useremail: '',userphone:'',}],
},
methods:{
searchData: _.debounce(function(){
if(this.message != '')
{
this.noresult = false;
this.arrayresults = [{id:'' ,username: '',useremail: '',userphone:'',}],
$.ajax({
type:'POST',
url: path+'usersearch',
data: {data:this.message},
success:(data) => {
if(data.length >= 1)
{
for(i = 0;i<data.length;i++)
{
this.arrayresults.push({id:data[i]['id'],username:data[i]['user_name'],useremail:data[i]['user_email'],userphone:data[i]['user_phone']})
}
this.ok = true;
}
else
{
this.ok = false;
this.noresult = true;
}
},
error:function()
{
console.log("error");
}
});
}
else
{
this.ok = false;
this.arrayresults = [{id:'' ,username: '',useremail: '',userphone:'',}];
}
},1000)
}
});
This is my laravel blade code:
<div v-if="ok" id='search-result' v-cloak>
<table class='table table-responsive thead-text' border='5'>
<thead>
<tr class='success'>
<td>{{trans('language.user_name')}}</td>
<td>{{trans('language.user_phone')}}</td>
<td>{{trans('language.user_email')}}</td>
<td>{{trans('language.settings')}}</td>
</tr>
</thead>
<tbody>
<tr v-for='(arrayresult ,key ,id) in arrayresults' class='warning'>
<td>@{{arrayresult.username}}</td>
<td>@{{arrayresult.userphone}}</td>
<td>@{{arrayresult.useremail}}</td>
<td class='hidden-print'>
<a v-bind:href="'/{{$path}}/users/' + arrayresult.id" class='btn btn-success'>{{trans('language.show')}}</a>
@can('users.update')<a v-bind:href="'/{{$path}}/users/' + arrayresult.id + '/edit'" class='btn btn-info'>{{trans('language.edit')}}</a>@endcan
</td>
</tr>
</tbody>
</table>
</div>
Everything is ok so far except that the first value is looking null without result when i set the array like this:
this.arrayresults = [{id:'' ,username: '',useremail: '',userphone:'',}],
The result shows like this:
I want to remove the first null value from the search.
this.arrayresults = [{id:'' ,username: '',useremail: '',userphone:'',}]
tothis.arrayresults = []
. – Pash