Documentation

AngularLoader
in package

The AngularLoader loads any JS/CSS/JSON resources required for setting up AngularJS.

This class is returned by 'angularjs.loader' service. Example use:

Civi::service('angularjs.loader')
  ->addModules('moduleFoo')
  ->useApp(); // Optional, if Civi's routing is desired (full-page apps only)
Tags
link
https://docs.angularjs.org/guide/bootstrap

Table of Contents

Constants

DEFAULT_MODULE_WEIGHT  = 200
The weight to assign to any Angular JS module files.

Properties

$angular  : Manager
The Angular module manager.
$crmApp  : array<string|int, mixed>|null
$modules  : array<string|int, mixed>
$modulesAlreadyLoaded  : array<string|int, mixed>
$pageName  : string
$region  : string
The region of the page into which JavaScript will be loaded.
$res  : CRM_Core_Resources
The resource manager.

Methods

__construct()  : mixed
AngularLoader constructor.
addModules()  : AngularLoader
findActiveModules()  : array<string|int, mixed>
Get a list of all Angular modules which should be activated on this page.
getAngular()  : Manager
getModules()  : array<string|int, mixed>
getPageName()  : string
getRegion()  : string
getRes()  : CRM_Core_Resources
load()  : $this
Calling this method from outside this class is deprecated.
onRegionRender()  : mixed
Loader service callback when rendering a page region.
setAngular()  : AngularLoader
setPageName()  : AngularLoader
setRegion()  : AngularLoader
setRes()  : AngularLoader
useApp()  : AngularLoader
Use Civi's generic "application" module.
isAllModules()  : int
loadAngularResources()  : mixed
Load scripts, styles & settings for the active modules.

Constants

DEFAULT_MODULE_WEIGHT

The weight to assign to any Angular JS module files.

public mixed DEFAULT_MODULE_WEIGHT = 200

Properties

$angular

The Angular module manager.

protected Manager $angular

Do not use publicly. Inject your own copy!

$crmApp

protected array<string|int, mixed>|null $crmApp = NULL

$modules

protected array<string|int, mixed> $modules

A list of modules to load.

$modulesAlreadyLoaded

protected array<string|int, mixed> $modulesAlreadyLoaded = []

When adding supplimental modules via snippet, these modules are already loaded.

$region

The region of the page into which JavaScript will be loaded.

protected string $region

Methods

__construct()

AngularLoader constructor.

public __construct() : mixed

findActiveModules()

Get a list of all Angular modules which should be activated on this page.

public findActiveModules() : array<string|int, mixed>
Return values
array<string|int, mixed>

List of module names. Ex: array('angularFileUpload', 'crmUi', 'crmUtil').

getModules()

public getModules() : array<string|int, mixed>
Return values
array<string|int, mixed>

getPageName()

public getPageName() : string
Return values
string

Ex: 'civicrm/a'.

getRegion()

public getRegion() : string
Return values
string

load()

Calling this method from outside this class is deprecated.

public load() : $this

Use the angularjs.loader service instead.

Return values
$this

onRegionRender()

Loader service callback when rendering a page region.

public onRegionRender(GenericHookEvent $e) : mixed

Loads Angular resources if any modules have been requested for this page.

Parameters
$e : GenericHookEvent

useApp()

Use Civi's generic "application" module.

public useApp([array<string|int, mixed> $settings = [] ]) : AngularLoader

This is suitable for use on a basic, standalone Angular page like civicrm/a. (If you need to integrate Angular with pre-existing, non-Angular pages... then this probably won't help.)

The Angular bootstrap process requires an HTML directive like <div ng-app="foo">.

Calling useApp() will replace the page's main body with the <div ng-app="crmApp">...</div> and apply some configuration options for the crmApp module.

Parameters
$settings : array<string|int, mixed> = []

A list of settings. Accepted values:

  • activeRoute: string, the route to open up immediately Ex: '/case/list'
  • defaultRoute: string, use this to redirect the default route (/) to another page Ex: '/case/list'
  • region: string, the place on the page where we should insert the angular app Ex: 'page-body'
Tags
link
https://code.angularjs.org/1.5.11/docs/guide/bootstrap
Return values
AngularLoader

isAllModules()

private isAllModules(mixed $moduleNames) : int
Parameters
$moduleNames : mixed
Return values
int

        
On this page

Search results