src/sample/sample.component.ts
This is a sample component to demonstrate how components should be written, and can be used as a template for new components
OnInit
AfterViewInit
OnDestroy
| selector | ibm-sample |
Methods |
|
Inputs |
Outputs |
constructor(_elementRef: ElementRef)
|
||||||||
|
Defined in src/sample/sample.component.ts:29
|
||||||||
|
instantiate services as private variables
Parameters :
|
foo
|
foo is an input that takes a SampleInterface
Type: |
|
Defined in src/sample/sample.component.ts:27
|
|
bar
|
bar is an event that emits a SampleInterface $event type: EventEmitter<SampleInterface>
|
|
Defined in src/sample/sample.component.ts:29
|
|
| Public doBar | ||||||||
doBar(value: )
|
||||||||
|
Defined in src/sample/sample.component.ts:54
|
||||||||
|
this is an instance method that can be used in templates
Parameters :
Returns :
void
|
| ngAfterViewInit |
ngAfterViewInit()
|
|
Defined in src/sample/sample.component.ts:44
|
|
run setup logic that depends on the DOM here
Returns :
void
|
| ngOnDestroy |
ngOnDestroy()
|
|
Defined in src/sample/sample.component.ts:49
|
|
clean up any event handlers or other objects that won't normally be destroyed
Returns :
void
|
| ngOnInit |
ngOnInit()
|
|
Defined in src/sample/sample.component.ts:39
|
|
run setup logic that doesnt depend on the DOM and only needs to be run once here
Returns :
void
|
| Protected setFoo | ||||||||
setFoo(value: SampleInterface)
|
||||||||
|
Defined in src/sample/sample.component.ts:59
|
||||||||
|
this is an instance method that can be inherited and used by subclasses
Parameters :
Returns :
void
|
import {
Component,
Input,
Output,
EventEmitter,
ElementRef,
OnInit,
AfterViewInit,
OnDestroy
} from "@angular/core";
import { SampleBase } from "./sample-base.class";
import { SampleInterface } from "./sample.interface";
/**
* This is a sample component to demonstrate how components should be written, and can be used as a template for new components
*/
@Component({
selector: "ibm-sample",
template: `
<p>Hello, Neutrino!</p>
<span>{{ foo.required }}</span>
`
})
export class Sample implements OnInit, AfterViewInit, OnDestroy {
/** foo is an input that takes a SampleInterface */
@Input() foo: SampleInterface;
/** bar is an event that emits a SampleInterface */
@Output() bar: EventEmitter<SampleInterface> = new EventEmitter<SampleInterface>();
/**
* instantiate services as private variables
*
* @param {ElementRef} _elementRef
*/
constructor(private _elementRef: ElementRef) {}
/** run setup logic that doesnt depend on the DOM and only needs to be run once here */
ngOnInit() {
//
}
/** run setup logic that depends on the DOM here */
ngAfterViewInit() {
//
}
/** clean up any event handlers or other objects that won't normally be destroyed */
ngOnDestroy() {
//
}
/** this is an instance method that can be used in templates */
public doBar(value) {
this.bar.emit(value);
}
/** this is an instance method that can be inherited and used by subclasses */
protected setFoo(value: SampleInterface) {
this.foo = value;
}
}