[enter image description here][1]
This what i want to accomplish ..that i can select the object in ionic-searchable
but when i put it in array which i have to fetch 3 object
here is the problem..
[enter image description here][2]
[1]: https://i.stack.imgur.com/GDfFW.png
i can't select the object...
[2]: https://i.stack.imgur.com/DjG4m.png
вот мой. html файл ..
<ion-item>
<select-searchable
item-content
[(ngModel)]="data"
placeholder="Select defects..."
[items]="problem"
[isMultiple]="true"
itemValueField="id"
itemTextField="defect"
(onChange)="onItemSelection($event)"
okButtonText="Add to Filter"
resetButtonText="Clear Selected"
(onClose)="onClose($event)"
[shouldStoreItemValue]="true"
cancelText="cancel"
[canClear]="true"
[canSearch]="true">
</select-searchable>
</ion-item>
</ion-list>
<div *ngFor="let defect of problem">
<ion-item *ngIf="defect.selected == true">
<ion-label>Area Problem: {{defect.defect}}<br>
</ion-label>
</ion-item>
</div>
<button ion-button full color="primary"
(click)="openFromCode()">Open Select</button>
вот мой .ts файл
import { SelectSearchableComponent} from 'ionic-
select-searchable';
@IonicPage()
@Component({
selector: 'page-form',
templateUrl: 'form.html',
})
export class FormPage {
@ViewChild('myselect') selectComponent:
SelectSearchableComponent;
data: any = [];
// data=null;
public title: string;
public subtitle: string;
public SelectedItemToFix: string = '';
defectId = [];
problem:any=[];
@Input('item') item: any;
constructor(public navCtrl: NavController,
public navParams: NavParams,
private http: HttpClient,
private storage: Storage,
private toastCtrl: ToastController,
public commonProv: CommonProvider) {
this.defect();
}
onItemSelection( event: { component:
SelectSearchableComponent, value: any}){
console.log('event:', event);
console.log(event.value);
for(var x = 0; x < this.problem.length; x++)
{
let selected_defect =
this.selectedDefects(event.value,this.problem[x]);
this.problem[x].selected = selected_defect;
}
};
selectedDefects(selected_value,problem)
{
for(var y = 0; y < selected_value.length; y++)
{
if(selected_value[y] == problem.id)
{
return true;
}
}
return false;
}
onClose() {
let toast = this.toastCtrl.create({
message: 'You successfully added an defect',
duration:2000
});
toast.present();
}
openFromCode(){
this.selectComponent.open();
}
defect(){
this.commonProv.getDefects().then(result=>{
this.problem = result;
// console.log(this.problem);
})
}
в laravel который является моим массивом бэкэнда i 3 объекта имя_области, имя_области, имя_дефекта.
вот код: publi c функция дефекты () {
$project_data_list = HouseDesignScopeofProblem::join('house_designs','house_design_scopeof_problems.house_design_id','=','house_designs.id')
->join('projects','house_designs.project_site_id','=','projects.id')
->join('area_problems','house_design_scopeof_problems.area_problem_id','=','area_problems.id')
->join('scope_of_the_problems','house_design_scopeof_problems.scope_of_the_problem_id','=','scope_of_the_problems.id')
->leftJoin('defects','defects.scope_of_the_problem_id','=','scope_of_the_problems.id')
->select(array('defects.id','house_designs.photo_name','area_problems.area_name','scope_of_the_problems.scope_name','defects.defect_name'))
->orderBy('area_problems.area_name')
->limit(10)
->get();
ARRAY $ дефект_арр = []; foreach ($ project_data_list as $ project_data) {
$defect_arr[]['defect'] = [$project_data->area_name,$project_data->scope_name,$project_data->defect_name];
}
// $defect_arr = Defects::all();
return response()->json( $defect_arr
);
}
, но когда я не помещаю его в массив, я могу выбрать объект следующим образом: введите описание изображения здесь
Может ли кто-нибудь помочь мне в этом Спасибо заранее ..