ContentElement
require(["esri/support/ContentElement"], function(ContentElement) { /* code goes here */ });
Object:
esri/support/ContentElement
Since: ArcGIS API for JavaScript 4.10
A convenience module for importing ContentElement classes when developing with TypeScript. For example, rather than importing content elements one at a time like this:
import Text = require("esri/support/ContentElement/Text");
import Media = require("esri/support/ContentElement/Media");
import Fields = require("esri/support/ContentElement/Fields");
import Attachments = require("esri/support/ContentElement/Attachments");
You can use this module to import them on a single line:
import { Text, Media, Fields, Attachments } from "esri/support/ContentElement";
This module also allows you to implement type guards on the content elements, making your code smarter.
import { ContentElement } from "esri/support/ContentElement";
function logContentElement(contentElement: ContentElement): void {
if (contentElement.type === "media") {
console.log("Content type is media");
}
else {
// The compiler knows the content element must be `text | fields | media | attachment`
console.log("The value is not a valid popup content element.")
}
}
Type Definitions
- Attachments
AttachmentsContentElement.
Popup content element types.
- FieldsFields
FieldsContentElement.
- MediaMedia
MediaContentElement.
- TextText
TextContentElement.
Loading...