I'm using ng-admin. I have two dropdown lists in a page, one for Provinces and the other for cities. I would like to populate choice of cities according to the value of the selected Province field. I can't load the whole list because it is humungous. What's the best way to do it? Here is my code:
dipendenti.creationView()
.title('Aggiungi dipendente')
.fields([
nga.field('Nome')
.validation({required: true })
.cssClasses('col-sm-4'),
nga.field('Cognome')
.validation({required: true })
.cssClasses('col-sm-4'),
nga.field('anagrafica.idprovincia','reference')
.label('Provincia')
.targetEntity(admin.getEntity('province'))
.targetField(nga.field('id'))
.targetField(nga.field('nome'))
.validation({required: true })
.cssClasses('col-sm-4'),
nga.field('anagrafica.idcitta','reference')
.label('Città')
.targetEntity(admin.getEntity('comuni'))
.targetField(nga.field('id'))
.targetField(nga.field('nome'))
.validation({required: true })
.permanentFilters({
provincia: 5}) //<- here shoud be retrieved automatically
// .remoteComplete(true, {
// refreshDelay: 300,
//// populate choices from the response of GET /posts?q=XXX
// searchQuery: function(search) { return { provincia: search }; } //<- here with autocomplete
// })
.cssClasses('col-sm-4')
I wonder if there is a way to inject a scope on the reference or the best practice for ng-admin...otherwise I think I shoud write an Angular directive...which is not exactly MY piece of cake...! I've looked at the code generated and it is a bit complicated ( I think I should replicate it as the directive's template ) so I'd prefer to find an elegant way to do the job. Thank you very much...