0

I'm trying to get my REST api which exposes my mongodb database to connect to ng-admin. I've had limited success, I can see the _id's in the interface once I've converted them from objects to strings.

specifically I'm having a problem with using the embedded_list field type to display sub labels. I am following the documentation and I just get the error

TypeError: t.map is not a function

at Function.i.value (http://172.28.128.3/bower_components/ng-admin/build/ng-admin.min.js:1:5980) [truncated...]

at ae (http://172.28.128.3/bower_components/ng-admin/build/ng-admin.min.js:23:3751)

<ma-embedded-list-column field="::field" value="::value" datastore="::datastore" class="ng-scope ng-isolate-scope">

My ng_admin config looks like

var myApp = angular.module('myApp', ['ng-admin']);
myApp.config(['NgAdminConfigurationProvider', function (nga) {
    // create an admin application
    var admin = nga.application('Keyword admin')
      .baseApiUrl('http://172.28.128.3/dictionary/'); // main API endpoint

    var keyword = nga.entity('keyword');
    // set the fields of the user entity list view
    keyword.listView().fields([
        nga.field('_id'),
        nga.field('labels', 'embedded_list') // Define a 1-N relationship with the (embedded) comment entity
        .targetFields([ // which comment fields to display in the datagrid / form
            //nga.field('sport'),
            nga.field('project'),
            nga.field('label')
        ])
    ]);

    //keyword.identifier(nga.field('_id.$id'));
    keyword.identifier(nga.field('_id'));

    admin.addEntity(keyword)
    nga.configure(admin);
}]);

and the out put from my api looks like (url /dictionary/keyword/56dd780e1163cf0d008b4568 )

{
  "_id": {
    "$id": "56dd780e1163cf0d008b4568"
  },
  "labels": [
    {
      "label": "the pyramid front left",
      "project": "core"
    }
  ],
  "_links": {
    "self": {
      "href": "http://172.28.128.3/dictionary/keyword/56dd780e1163cf0d008b4568"
     }
  } 
}
Max B
  • 42
  • 8

1 Answers1

0

The issue here is that $labels isn't an array, I'd done an $unwind in the mongodb aggregate function and not undone it before returning the data.

Max B
  • 42
  • 8