Return all the attributes(fields) in a feature layer for a PopupTemplate - ArcGis Javascript

01-03-2022 02:23 AM
New Contributor

Is there a way to return all the attributes(fields) in a feature layer for a PopupTemplate, without declaring all of them in the fieldInfos object in Angular?


const template = {
        title: "{NAME} in {COUNTY}",
        content: ,
        fieldInfos : fieldInfos
     const layer = new FeatureLayer({
      url: this.featureLayerUrl,
      visible: true,
      popupTemplate : template
      var fieldInfos =, function(field){
         return {
                "label": field.alias,
                "visible": true



    <!-- Map Div -->

I’m using arcgis-js-api version 4.2.1.
But when I use this example it is working. (But I want to set these fields dynamically.)

const fields = [{
  name: "NAME",
  alias: "Name",
  type: "string"
    }, {
  name: "County",
  alias: "County",
  type: "string"
}, {
const config = {
  fields: fields,
  title: "County land"


0 Kudos
2 Replies
Frequent Contributor

You can use the createPopupTemplate method on the layer.

view.when(() => {
  const popupTemplate = featureLayer.createPopupTemplate();
  featureLayer.popupTemplate = popupTemplate;
0 Kudos
Esri Regular Contributor

You also need to set MapView.popup.defaultPopupTemplateEnabled to true on top of what @ReneRubalcava  pointed out.



0 Kudos