Posts

Showing posts with the label Angular common

Angular NgIf

directive A structural directive that conditionally includes a template based on the value of an expression coerced to Boolean. When the expression evaluates to true, Angular renders the template provided in a then clause, and when false or null, Angular renders the template provided in an optional else clause. The default template for the else clause is blank. See more... Exported from CommonModule Selectors [ ngIf] Properties Property Description @ Input() ngIf : T Write-Only The Boolean expression to evaluate as the condition for showing a template. @ Input() ngIfThen : TemplateRef< NgIfContext<T>> Write-Only A template to show if the condition expression evaluates to true. @ Input() ngIfElse : TemplateRef< NgIfContext<T>> Write-Only A template to show if the condition expression evaluates to false. Description A shorthand form of the directive, * ngIf="condition" , is generally used, p...

Angular NgSwitch Example

directive The [ngSwitch] directive on a container specifies an expression to match against. The expressions to match are provided by ngSwitchCase directives on views within the container. Every view that matches is rendered. If there are no matches, a view with the ngSwitchDefault directive is rendered. Elements within the [ NgSwitch] statement but outside of any NgSwitchCase or ngSwitchDefault directive are preserved at the location. See also NgSwitchCase NgSwitchDefault Structural Directives Exported from CommonModule Selectors [ ngSwitch] Properties Property Description @ Input() ngSwitch : any Write-Only Description Define a container element for the directive, and specify the switch expression to match against as an attribute: <container-element [ngSwitch]="switch_expression"> Within the container, * ngSwitchCase statements specify the match expressions as attributes. Include * ngSwitchDefault as t...

Angular FormatDate

function Formats a date according to locale rules. formatDate(value: string | number | Date, format: string, locale: string, timezone?: string): string Parameters value string | number | Date The date to format, as a Date, or a number (milliseconds since UTC epoch) or an ISO date-time string. format string The date-time components to include. See DatePipe for details. locale string A locale code for the locale format rules to use. timezone string The time zone. A time zone offset from GMT (such as '+0430' ), or a standard UTC/GMT or continental US time zone abbreviation. If not specified, uses host system settings. Optional. Default is undefined . Returns string : The formatted date string. See also DatePipe Internationalization (i18n) Guide

Angular NgTemplateOutlet Example

directive Inserts an embedded view from a prepared TemplateRef . See more... Exported from CommonModule Selectors [ ngTemplateOutlet] Properties Property Description @ Input() ngTemplateOutletContext : Object | null A context object to attach to the EmbeddedViewRef . This should be an object, the object's keys will be available for binding by the local template let declarations. Using the key $implicit in the context object will set its value as default. @ Input() ngTemplateOutlet : TemplateRef<any> | null A string defining the template reference and optionally the context object for the template. Description You can attach a context object to the EmbeddedViewRef by setting [ngTemplateOutletContext] . [ngTemplateOutletContext] should be an object, the object's keys will be available for binding by the local template let declarations. <ng-container *ngTemplateOutlet="templateRefExp; context: contextExp"...