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?
.ts
const template = { title: "{NAME} in {COUNTY}", content: , fieldInfos : fieldInfos }; const layer = new FeatureLayer({ url: this.featureLayerUrl, visible: true, popupTemplate : template }); var fieldInfos = layer.map(layer.fields, function(field){ return { "fieldName": field.name, "label": field.alias, "visible": true webmap.add(layer);
.html
<!-- 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" };
You can use the createPopupTemplate method on the layer.
view.when(() => {
const popupTemplate = featureLayer.createPopupTemplate();
featureLayer.popupTemplate = popupTemplate;
});
You also need to set MapView.popup.defaultPopupTemplateEnabled to true on top of what @ReneRubalcava pointed out.