Hurry Up, Ends March 14!

ContentStrategy

ContentStrategy is an abstract class exposed by @abp/ng.core package. It helps you create inline scripts or styles.

API

constructor

constructor(
  public content: string,
  protected domStrategy?: DomStrategy,
  protected contentSecurityStrategy?: ContentSecurityStrategy
)
JavaScript
  • content is set to <script> and <style> elements as textContent property.
  • domStrategy is the DomStrategy that will be used when inserting the created element. (default: AppendToHead)
  • contentSecurityStrategy is the ContentSecurityStrategy that will be used on the created element before inserting it. (default: None)

Please refer to DomStrategy and ContentSecurityStrategy documentation for their usage.

createElement

createElement(): HTMLScriptElement | HTMLStyleElement
JavaScript

This method creates and returns a <script> or <style> element with content set as textContent.

insertElement

insertElement(): void
JavaScript

This method creates and inserts a <script> or <style> element.

ScriptContentStrategy

ScriptContentStrategy is a class that extends ContentStrategy. It lets you insert a <script> element to the DOM.

StyleContentStrategy

StyleContentStrategy is a class that extends ContentStrategy. It lets you insert a <style> element to the DOM.

Predefined Content Strategies

Predefined content strategies are accessible via CONTENT_STRATEGY constant.

AppendScriptToBody

CONTENT_STRATEGY.AppendScriptToBody(content: string)
JavaScript

Creates a <script> element with the given content and places it at the end of <body> tag in the document.

AppendScriptToHead

CONTENT_STRATEGY.AppendScriptToHead(content: string)
JavaScript

Creates a <script> element with the given content and places it at the end of <head> tag in the document.

AppendStyleToHead

CONTENT_STRATEGY.AppendStyleToHead(content: string)
JavaScript

Creates a <style> element with the given content and places it at the end of <head> tag in the document.

PrependStyleToHead

CONTENT_STRATEGY.PrependStyleToHead(content: string)
JavaScript

Creates a <style> element with the given content and places it at the beginning of <head> tag in the document.

See Also

Contributors


Last updated: April 07, 2020 Edit this page on GitHub

Was this page helpful?

Please make a selection.

To help us improve, please share your reason for the negative feedback in the field below.

Please enter a note.

Thank you for your valuable feedback!

Please note that although we cannot respond to feedback, our team will use your comments to improve the experience.

Community Talks

Real World Problems and Solutions with AI

27 Feb, 17:00
Online
Watch the Event
Learn More, Pay Less
33% OFF
All Trainings!
Get Your Deal
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book