src/redhawk/redhawk.directive.ts
The REDHAWK Directive is the entry point, top-level directive for dependency injection when accessing the REST services for a REDHAWK Domain.
<div arRedhawk [(arModel)]="my_model">
providers |
()
|
selector | [arRedhawk] |
Properties |
|
Methods |
Inputs |
Outputs |
constructor(service: RedhawkService)
|
||||||||
Defined in src/redhawk/redhawk.directive.ts:40
|
||||||||
Constructor
Parameters :
|
arModel
|
Setter for "Banana in a Box Syntax"
Type: |
Defined in src/redhawk/redhawk.directive.ts:35
|
serviceName
|
The name to apply to the REDHAWK Service
Type: |
Defined in src/redhawk/redhawk.directive.ts:32
|
arModelChange
|
Emitter for "Banana in a Box Syntax" $event type: EventEmitter<Redhawk>
|
Defined in src/redhawk/redhawk.directive.ts:37
|
ngOnDestroy |
ngOnDestroy()
|
Defined in src/redhawk/redhawk.directive.ts:66
|
Implementation of the OnDestroy interface unsubscribes from the model observable.
Returns :
void
|
ngOnInit |
ngOnInit()
|
Defined in src/redhawk/redhawk.directive.ts:59
|
Implementation of the OnChanges interface updates the service's uniqueID
Returns :
void
|
Public service |
service:
|
Type : RedhawkService
|
Defined in src/redhawk/redhawk.directive.ts:47
|
The service either imported from up the hierarchy or instantiated by this directive. |
Private subscription |
subscription:
|
Type : Subscription
|
Defined in src/redhawk/redhawk.directive.ts:40
|
Internal subscription for the model |
import {
Directive,
OnInit,
OnDestroy,
Input,
Output,
EventEmitter
} from '@angular/core';
import { Subscription } from 'rxjs/Subscription';
import { Redhawk } from '../models/index';
import { RedhawkService } from './redhawk.service';
import { redhawkServiceProvider } from './redhawk-service-provider';
/**
* The REDHAWK Directive is the entry point, top-level directive for dependency
* injection when accessing the REST services for a REDHAWK Domain.
*
* @example
* <div arRedhawk [(arModel)]="my_model">
*/
@Directive({
selector: '[arRedhawk]',
exportAs: 'arRedhawk',
providers: [
redhawkServiceProvider()
]
})
export class RedhawkDirective implements OnInit, OnDestroy {
/** The name to apply to the REDHAWK Service */
@Input() serviceName: string;
/** Setter for "Banana in a Box Syntax" */
@Input('arModel') model: Redhawk;
/** Emitter for "Banana in a Box Syntax" */
@Output('arModelChange') modelChange: EventEmitter<Redhawk>;
/** Internal subscription for the model */
private subscription: Subscription;
/**
* Constructor
* @param service The service either imported from up the hierarchy or instantiated
* by this directive.
*/
constructor(public service: RedhawkService) {
this.modelChange = new EventEmitter<Redhawk>();
this.subscription = this.service.model$.subscribe(it => {
this.model = it;
this.modelChange.emit(this.model);
});
}
/**
* Implementation of the OnChanges interface updates the service's uniqueID
* @param changes The changes made to this component
*/
ngOnInit() {
this.service.uniqueId = this.serviceName || 'Default';
}
/**
* Implementation of the OnDestroy interface unsubscribes from the model observable.
*/
ngOnDestroy() {
this.subscription.unsubscribe();
}
}