ContainerStrategy

ContainerStrategy is an abstract class exposed by @abp/ng.core package. There are two container strategies extending it: ClearContainerStrategy and InsertIntoContainerStrategy. Implementing the same methods and properties, both of these strategies help you define how your containers will be prepared and where your content will be projected.

API

ClearContainerStrategy is a class that extends ContainerStrategy. It lets you clear a container before projecting content in it.

constructor

constructor(
  public containerRef: ViewContainerRef,
  private index?: number, // works only in InsertIntoContainerStrategy
)
JavaScript
  • containerRef is the ViewContainerRef that will be used when projecting the content.

getIndex

getIndex(): number
JavaScript

This method return the given index clamped by 0 and length of the containerRef. For strategies without an index, it returns 0.

prepare

prepare(): void
JavaScript

This method is called before content projection. Based on used container strategy, it either clears the container or does nothing (noop).

ClearContainerStrategy

ClearContainerStrategy is a class that extends ContainerStrategy. It lets you clear a container before projecting content in it.

InsertIntoContainerStrategy

InsertIntoContainerStrategy is a class that extends ContainerStrategy. It lets you project your content at a specific node index in the container.

Predefined Container Strategies

Predefined container strategies are accessible via CONTAINER_STRATEGY constant.

Clear

CONTAINER_STRATEGY.Clear(containerRef: ViewContainerRef)
JavaScript

Clears given container before content projection.

Append

CONTAINER_STRATEGY.Append(containerRef: ViewContainerRef)
JavaScript

Projected content will be appended to the container.

Prepend

CONTAINER_STRATEGY.Prepend(containerRef: ViewContainerRef)
JavaScript

Projected content will be prepended to the container.

Insert

CONTAINER_STRATEGY.Insert(
  containerRef: ViewContainerRef,
  index: number,
)
JavaScript

Projected content will be inserted into to the container at given index (clamped by 0 and length of the containerRef).

See Also

Contributors


Last updated: April 09, 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
Boost Your Development
ABP Live Training
Packages
See Trainings
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