0

This is a part of my code that I get this error:

Expected 2 arguments, but got 1.ts(2554)
core.d.ts(8054, 47): An argument for 'opts' was not provided.

from here:

import {ViewChild, ChangeDetectorRef, AfterViewInit} from "@angular/core"; 
import {RadSideDrawerComponent, SideDrawerType} from "nativescript-telerik-ui/sidedrawer/angular";

export class DrawerPage implements AfterViewInit {
    @ViewChild(RadSideDrawerComponent) protected drawerComponent: RadSideDrawerComponent; 
    protected drawer: SideDrawerType;

    constructor(private _changeDetectorRef: ChangeDetectorRef) { }

    ngAfterViewInit() { 
        this.drawer = this.drawerComponent.sideDrawer; 
        this._changeDetectorRef.detectChanges(); 
    }

    protected openDrawer() { 
        this.drawer.showDrawer(); 
    }

    protected closeDrawer() { 
        this.drawer.closeDrawer(); 
    }
}

I can't understand what is the problem? I am new learner who follows a tutorial video to learn NativeScript!

Hasani
  • 3,543
  • 14
  • 65
  • 125

2 Answers2

2

In Angular 8 , ViewChild takes 2 parameters:

Try like this:

@ViewChild('nameInput', { static: false }) nameInputRef: ElementRef;

Explanation:

{ static: false }

If you set static false, the component ALWAYS gets initialized after the view initialization in time for the ngAfterViewInit/ngAfterContentInit callback functions.

{ static: true}

If you set static true, the initialization will take place at the view initialization at ngOnInit

By default you can use { static: false }. If you are creating a dynamic view and want to use the template reference variable, then you should use { static: true}

For more info, you can read this here

Thank you.

0

You are using nativescript-telerik-ui/sidedrawer and that is not supported by latest version of Nativscript.This package has been deprecated.

For side drawer, use nativescript-ui-sidedrawer.

Narendra
  • 4,514
  • 2
  • 21
  • 38