ContentStrategy
ContentStrategy
is an abstract class exposed by @abp/ng.core package. It helps you create inline scripts or styles.
API
constructor
content
is set to<script>
and<style>
elements astextContent
property.domStrategy
is theDomStrategy
that will be used when inserting the created element. (default: AppendToHead)contentSecurityStrategy
is theContentSecurityStrategy
that will be used on the created element before inserting it. (default: None)
Please refer to DomStrategy and ContentSecurityStrategy documentation for their usage.
createElement
This method creates and returns a <script>
or <style>
element with content
set as textContent
.
insertElement
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
Creates a <script>
element with the given content and places it at the end of <body>
tag in the document.
AppendScriptToHead
Creates a <script>
element with the given content and places it at the end of <head>
tag in the document.
AppendStyleToHead
Creates a <style>
element with the given content and places it at the end of <head>
tag in the document.
PrependStyleToHead
Creates a <style>
element with the given content and places it at the beginning of <head>
tag in the document.