Search
 
SCRIPT & CODE EXAMPLE
 

HTML

declare variable in html angular

We can just create directive like *ngIf and call it *ngVar

ng-var.directive.ts

@Directive({
    selector: '[ngVar]',
})
export class VarDirective {
    @Input()
    set ngVar(context: unknown) {
        this.context.$implicit = this.context.ngVar = context;

        if (!this.hasView) {
            this.vcRef.createEmbeddedView(this.templateRef, this.context);
            this.hasView = true;
        }
    }

    private context: {
        $implicit: unknown;
        ngVar: unknown;
    } = {
        $implicit: null,
        ngVar: null,
    };

    private hasView: boolean = false;

    constructor(
        private templateRef: TemplateRef<any>,
        private vcRef: ViewContainerRef
    ) {}
}

with this *ngVar directive we can use the following

<div *ngVar="false as variable">
      <span>{{variable | json}}</span>
</div>
Comment

angular html variable

We can just create directive like *ngIf and call it *ngVar

ng-var.directive.ts

@Directive({
    selector: '[ngVar]',
})
export class VarDirective {
    @Input()
    set ngVar(context: unknown) {
        this.context.$implicit = this.context.ngVar = context;

        if (!this.hasView) {
            this.vcRef.createEmbeddedView(this.templateRef, this.context);
            this.hasView = true;
        }
    }

    private context: {
        $implicit: unknown;
        ngVar: unknown;
    } = {
        $implicit: null,
        ngVar: null,
    };

    private hasView: boolean = false;

    constructor(
        private templateRef: TemplateRef<any>,
        private vcRef: ViewContainerRef
    ) {}
}

with this *ngVar directive we can use the following

<div *ngVar="false as variable">
      <span>{{variable | json}}</span>
</div>
Comment

angular variable in html

We can just create directive like *ngIf and call it *ngVar

ng-var.directive.ts

@Directive({
    selector: '[ngVar]',
})
export class VarDirective {
    @Input()
    set ngVar(context: unknown) {
        this.context.$implicit = this.context.ngVar = context;

        if (!this.hasView) {
            this.vcRef.createEmbeddedView(this.templateRef, this.context);
            this.hasView = true;
        }
    }

    private context: {
        $implicit: unknown;
        ngVar: unknown;
    } = {
        $implicit: null,
        ngVar: null,
    };

    private hasView: boolean = false;

    constructor(
        private templateRef: TemplateRef<any>,
        private vcRef: ViewContainerRef
    ) {}
}

with this *ngVar directive we can use the following

<div *ngVar="false as variable">
      <span>{{variable | json}}</span>
</div>
Comment

PREVIOUS NEXT
Code Example
Html :: html cheetsheet.com 
Html :: ONLINE VIDEO CALL FOR MY WEBSITE CODE 
Html :: wrap text around image bootstrap 
Html :: BEM example html 
Html :: animate text 
Html :: all meta og tags 
Html :: create a close x button in html 
Html :: how to make a button download a file in html 
Html :: dropdown 
Html :: highlight 
Html :: link a hyperlink from different folder 
Html :: petition to get rid of pigeons 
Html :: tina4 form token example 
Html :: html marquee space between images 
Html :: balise li forme valider 
Html :: kode vidio dalam html 
Html :: flexbox afbeeldingen 
Html :: laravel route explicit binding 
Html :: htmlchat 
Html :: when I refresh my page it comes back to the same place html 
Html :: Howt o get redirected to another page using a button in HTML using Python using Flask 
Html :: Remover Acentos 
Html :: time sequelize html example stack overflow 
Html :: Style 
Html :: html to editable react-draft-wysiwyg 
Html :: hii 
Html :: flex box wrap generator 
Html :: modal trava bootstrap 
Html :: data-parsley confirm password 
Html :: Div positioning HTML 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =