Я не могу включить отношения в метод findRecord()
.У меня уже есть та же ошибка:
parseHasMany - Тип модели для узла отношения - не найдена позиция.
и я не понимаю, почему?
my dataStore.service
import { Injectable } from '@angular/core';
import { JsonApiDatastoreConfig, JsonApiDatastore, DatastoreConfig } from 'angular2-jsonapi';
import { HttpClient } from '@angular/common/http';
import { environment } from '../../../environments/environment';
import { Etablissement } from '@models/etablissement.model';
import { Emplacement } from '@models/emplacement.model';
import { Page } from '@models/page.model';
const config: DatastoreConfig = {
baseUrl: environment.api.baseUrl + 'jsonapi',
models: {
page: Page,
emplacement: Emplacement,
etablissement: Etablissement
}
};
@Injectable({
providedIn: 'root'
})
@JsonApiDatastoreConfig(config)
export class DatastoreService extends JsonApiDatastore{
constructor(http: HttpClient) {
super(http);
}
}
my etablissement.model
import { JsonApiModelConfig, JsonApiModel, Attribute, HasMany, BelongsTo } from 'angular2-jsonapi';
import { Emplacement } from '@models/emplacement.model';
@JsonApiModelConfig({
type: 'node/etablissement'
})
export class Etablissement extends JsonApiModel{
@Attribute()
title: string;
@Attribute()
field_key: string;
@Attribute()
field_commentaires: string;
@Attribute()
field_description: string;
@Attribute()
field_ess: boolean;
@Attribute()
field_mail: string;
@Attribute()
field_monnaies: string;
@Attribute()
field_ref_categories: string;
@HasMany()
field_ref_emplacement: Emplacement[];
@Attribute()
field_label: string;
@Attribute()
field_verifie: boolean;
}
my emplacement.model
import { JsonApiModelConfig, JsonApiModel, Attribute, HasMany, BelongsTo } from 'angular2-jsonapi';
@JsonApiModelConfig({
type: 'node/emplacement'
})
export class Emplacement extends JsonApiModel{
@Attribute()
title: string;
@Attribute()
body: string;
@Attribute()
field_coordonnee: Geolocation;
@Attribute()
field_horaires: string;
@Attribute()
field_telephone: string;
@Attribute()
field_nom_emplacement: string;
}
и мой entreprise.component
import { Component, OnInit } from '@angular/core';
import { ErrorResponse } from "angular2-jsonapi";
import { DatastoreService } from '@app/shared/services/datastore.service';
import { Etablissement } from '@models/etablissement.model';
@Component({
selector: 'app-entreprise',
templateUrl: './entreprise.component.html',
styleUrls: ['./entreprise.component.scss']
})
export class EntrepriseComponent implements OnInit {
etablissement : any = false;
constructor(private datastore: DatastoreService) { }
ngOnInit() {
this.getEnt('7338dfea-9bd2-4c61-b8be-df4ed1493c19');
}
getEnt(uuid: string){
this.datastore.findRecord(Etablissement, uuid, {
include: 'field_ref_emplacement'
})
.subscribe(
(etablissement: Etablissement) => {
console.log(etablissement);
},
(error: ErrorResponse) => {
console.log(error);
}
);
}
}
(извините за дисплей, я впервые! И для моего английского я тоже француз!)