LoadingStrategy
LoadingStrategy
is an abstract class exposed by @abp/ng.core package. There are two loading strategies extending it: ScriptLoadingStrategy
and StyleLoadingStrategy
. Implementing the same methods and properties, both of these strategies help you define how your lazy loading will work.
API
constructor
path
is set to<script>
elements assrc
and<link>
elements ashref
attribute.domStrategy
is theDomStrategy
that will be used when inserting the created element. (default: AppendToHead)crossOriginStrategy
is theCrossOriginStrategy
that will be used on the created element before inserting it. (default: Anonymous)
Please refer to DomStrategy and CrossOriginStrategy documentation for their usage.
createElement
This method creates and returns a <script>
or <link>
element with path
set as src
or href
.
createStream
This method creates and returns an observable stream that emits on success and throws on error.
ScriptLoadingStrategy
ScriptLoadingStrategy
is a class that extends LoadingStrategy
. It lets you lazy load a script.
StyleLoadingStrategy
StyleLoadingStrategy
is a class that extends LoadingStrategy
. It lets you lazy load a style.
Predefined Loading Strategies
Predefined loading strategies are accessible via LOADING_STRATEGY
constant.
AppendAnonymousScriptToHead
Sets given paremeters and crossorigin="anonymous"
as attributes of created <script>
element and places it at the end of <head>
tag in the document.
PrependAnonymousScriptToHead
Sets given paremeters and crossorigin="anonymous"
as attributes of created <script>
element and places it at the beginning of <head>
tag in the document.
AppendAnonymousScriptToBody
Sets given paremeters and crossorigin="anonymous"
as attributes of created <script>
element and places it at the end of <body>
tag in the document.
AppendAnonymousStyleToHead
Sets given paremeters and crossorigin="anonymous"
as attributes of created <style>
element and places it at the end of <head>
tag in the document.
PrependAnonymousStyleToHead
Sets given parameters and crossorigin="anonymous"
as attributes of created <style>
element and places it at the beginning of <head>
tag in the document.