General Knowledge Flashcards
How does ng-Content differ from string Interpolation {{myValue}}?
Show Example
String interpolation comes from the myValue in the current component while ng-Content comes from the parent component.
<xxx> <p>Mary Had a Little Lamb</p>
<br></br> <div>Commercial Break</div> <xxx></xxx></xxx>
Where xxx is defined as:
heading goes here
<ng-content></ng-content>
<—- this is the p and div from above
footer goes here
List the 8 life-cycle hooks in order.
- ngOnChanges()
- ngOnInit()
- ngDoCheck()
- ngAfterContentInit() - after Angular projects external content into the component’s view
- ngAfterContentChecked() - after the ngAfterContentInit() and every subsequent ngDoCheck()
- ngAfterViewInit() -Called once after the first ngAfterContentChecked()
- ngAfterViewChecked() - Called after the ngAfterViewInit and every subsequent ngAfterContentChecked()
- ngOnDestroy()
What module in AppModule contains all the base functionality that is required by Angular?
BrowserModule
Show how to make a Component selector (‘app-server’) be an attribute type.
Show it in use.
selector: ‘[app-server]’
…
Show how to make a Component selector (‘app-server’) be an class.
Show it in use.
selector: ‘.app-server’
…
Explain the use of square brackets in HTML.
Applied to an attribute that is already valid for the selector,
indicates the value of that property will be bound to the expression after the equal sign.
Otherwise, if the attribute is NOT a part of the selector,
it still binds to a variable, but here it is a directive.
Show how to change what appears between the opening and closing tags of an element such as in
(See image)
(see image)
innerText is a native DOM element.
allowNewServer is a boolean which will be converted to string
Show the attributes that are native DOM vs Angular for triggering a click event.
native: onclick=””
Angular: (click)=””
Is this valid: (click)=”status = true ? ‘okay’ : ‘not okay’ “
yes, it can work with expressions.
What is the attribute for the DOM input element that will trigger every time a character is entered or removed.
(input)=” ourFunction( $event ) “
ourFunction(event: Event ) { // or event: any
this.serverName = (event.target).value;
What must be added to the App NgModule Imports in order to use two-way event binding with [(ngModel)] ?
import FormsModule which is from ‘@angular/forms’
What is the syntax of the directive selector field?
selector: “ [myDirective] “
square brackets
what indicates a “local reference” to an element in HTML?
Starts with hash sign #
Show the syntax of ngIf with else.
See attached image
…
Show the format of ngStyle directive.
(See Attached Image)