File

universal/src/directives/server-only.directive.ts

Description

Renders the marked element only on server platforms.

Extends

PlatformDirective

Metadata

Index

Methods

Methods

Protected shouldRender
shouldRender()
Inherited from PlatformDirective

Checks whether the element should be rendered on the current platform.

Returns: boolean
ngOnInit
ngOnInit()
Inherited from PlatformDirective

Checks whether the element should be rendered on the current platform and renders it.

Returns: void
import { Directive } from '@angular/core';

import { PlatformDirective } from './platform.directive';

/**
 * Renders the marked element only on server platforms.
 *
 * @export
 * @class ServerOnlyDirective
 * @extends {PlatformDirective}
 */
@Directive({
    selector: '[serverOnly]'
})
export class ServerOnlyDirective extends PlatformDirective
{
    /**
     * Checks whether the element should be rendered on the current platform.
     *
     * @protected
     * @returns {boolean}
     */
    protected shouldRender(): boolean
    {
        return this.universal.isPlatformServer;
    }
}

results matching ""

    No results matching ""