BackgroundClass ComponentController

This class is mainly working behind the scenes. Every component ina Mahalo application has its controller. The controller is responsiblefor knowing how a component relates to other components and alsofor managing its attached behaviors.

The most common use for this class is to inject the correct controllerinto a Component or a Behavior. You can then useit to traverse the tree of controllers and find relevant parents orchildren.

You can also use it to create children inside of your component on the fly.Have a look at the source of Show for a simple example of this.

alias

{ default } from mahalo/app/component-controller

Hierarchy

  • ComponentController

Implements

Index

Constructors

constructor

  • Prepares the controler for beeing initialized. This means it will set the correctdependencies for injection and create the component.

    Parameters
    Returns ComponentController

Properties

behaviors

behaviors:Set<Behavior>

The component's behaviors.

children

children:Set<IController>

The child controllers.

compiled

compiled:boolean

A flag that indicates if the controller was already compiled.

component

component:Component

The component instance of the controller.

isEntering

isEntering:boolean

This flag indicates if the controller is currently running its entering animation.

isLeaving

isLeaving:boolean

This flag indicates if the controller is currently running its leaving animation.

localScope

localScope:Scope | Component

The controller's localScope.

locals

locals:string[]

The keys that should be available in the local scope.

node

node:Element | DocumentFragment

The defining element of the template.

parent

The parent controller.

position

position:number

The current postion of the controller inside its parent.

scope

The scope inside which the component was defined.

Methods

append

  • append(parentNode: Element | DocumentFragment): void
  • Appends the controller's element to the DOM and performs anoptional entering animation.

    Parameters
    • parentNode: Element | DocumentFragment
    Returns void

Private compileChildren

  • Parameters
    Returns void

detach

  • detach(): void
  • Runs an optional leaving animation and executes the remove method.

    Returns void

init

  • init(parentNode: Element | DocumentFragment, children: IGenerator[], behaviors: Object, template?: Template): void
  • This method will create the local scope, compile the controller's childrenwith the correct dependencies and after that initialize the controller'sbehaviors.

    Parameters
    • parentNode: Element | DocumentFragment
    • children: IGenerator[]
    • behaviors: Object
    • Optional template: Template
    Returns void

Private initBehaviors

  • initBehaviors(behaviors: Object): void
  • Parameters
    • behaviors: Object
    Returns void

remove

  • remove(): void
  • Removes all bindings that were made by the controller's component or its childrenand removes the controller's element from the DOM.

    Returns void

removeChildren

  • removeChildren(): void
  • Recursively destroys the controller's children.

    Returns void