`Cannot retrieve object`

this.deleteValue = {
            LanguageId : '',
            LanguageName : '',
            LongName : '',
            CreatedBy : '',
            UpdatedBy : '',
            CreatedDate : '',
            UpdateDate : '',
            IsDeleted : ''
        }

I have initialized a variable called "deleteValue" in my component and assigned a value to it within one of my functions.

beginDel(delValue){
        this.deleteValue = new language(delValue.LanguageId, delValue.LanguageName, delValue.LongName, delValue.CreatedBy, delValue.UpdatedBy,delValue.CreatedDate,delValue.UpdateDate, delValue.IsDeleted);  
        console.log(this.deleteValue);  

    }

However, when I try to access the deleteValue variable in another function, it is showing up as an empty object.

 recordDel(){
        console.log(this.deleteValue);
}

I suspect that there might be an issue with scoping, but I am unable to pinpoint the exact problem.

Answer №1

When re-initializing it in beginDel, make sure to invoke this method from within beginDel as shown below:

 beginDel(delValue){
     ....
     ....    
     // include chain-call here
     recordDel();
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using the js-cookie library in a TypeScript-based project: A guide

Looking to incorporate the js-cookie library into my TypeScript project. After installing the library and typings with the command npm install js-cookie @types/js-cookie --save-dev in the location containing node_modules and package.json, my package.json ...

KeysOfType: Identifying the precise data type of each property

I came across a solution called KeysOfType on a post at : type KeysOfType<T, TProp> = { [P in keyof T]: T[P] extends TProp? P : never }[keyof T]; Here are the interfaces being used: interface SomeInterface { a: number; b: string; } interface A ...

Personalize the Ag-Grid Status Bar to your liking

Currently utilizing Ag-Grid Enterprise, Version 19 ("ag-grid-angular": "19.0.0", "ag-grid-community": "19.0.0", "ag-grid-enterprise": "19.0.0") in conjunction with Angular 4. There is a specific need to customize the status bar of the grid and add an add ...

Whenever signing in with Next Auth, the response consistently exhibits the values of "ok" being false and "status" being 302, even

I am currently using Next Auth with credentials to handle sign-ins. Below is the React sign-in function, which can be found at this link. signIn('credentials', { redirect: false, email: email, password: password, ...

Limit the selection of 'pickable' attributes following selections in the picking function (TypeScript)

In the codebase I'm working on, I recently added a useful util function: const pick = <T extends object, P extends keyof T, R = Pick<T,P>>( obj: T, keys: P[] ): R => { if (!obj) return {} as R return keys.reduce((acc, key) => { re ...

Establishing the starting value for Angular 2's reactive FormArray

I am having trouble setting the initial value for an angular 2 reactive form formArray object. Despite using a json object with multiple entries to set the form value, only the first entry is displayed and "form.value" also only shows the first entry. To ...

Creating a sidebar in Jupyter Lab for enhanced development features

Hi there! Recently, I've been working on putting together a custom sidebar. During my research, I stumbled upon the code snippet below which supposedly helps in creating a simple sidebar. Unfortunately, I am facing some issues with it and would greatl ...

I encountered an issue while trying to install the Angular and npm package

After updating Nodejs, I decided to delete the old version of Angular and install a new one. However, I encountered an error during the installation process. https://i.sstatic.net/M5VOc.png I followed a series of steps in an attempt to resolve the issue, ...

The CSS formatting is not being properly applied within the innerHTML

I have a scenario where I am trying to display a Bootstrap card using innerHTML in my TS file, but the styles are not being applied to this content. I suspect that the issue might be because the styles are loaded before the component displays the card, cau ...

Angular does not apply the ng-content class

I am facing an issue with my application where I have a layout that includes a div element with 2 ng-content tags. However, the classes are not being applied correctly. <div class="col-12 pr-1 pl-0 row m-0 p-0"> <ng-content class=&qu ...

Struggling to comprehend the intricacies of these generic declarations, particularly when it comes to Type Argument Lists

I'm currently reviewing the code snippet from the TypeScript definitions of fastify. I am struggling to understand these definitions. Although I am familiar with angle brackets used for generics, most TypeScript tutorials focus on simple types like Ar ...

Creating a TypeScript frozen set: A step-by-step guide

Imagine having a group of values that you want to protect from being edited, as shown below: // These values should not be editable. const listenedKeys = new Set(['w', 'a', 's', 'd']) // This value can be accessed w ...

typescriptIs it possible to disregard the static variable and ensure that it is correctly enforced

I have the following code snippet: export class X { static foo: { bar: number; }; } const bar = X.foo.bar Unfortunately, it appears that TypeScript doesn't properly detect if X.foo could potentially be undefined. Interestingly, TypeScript ...

Issue with obtaining access token in Angular 8 authentication flow with Code Flow

As I work on implementing SSO login in my code, I encounter a recurring issue. Within my app.module.ts, there is an auth.service provided inside an app initializer. Upon hitting the necessary service and capturing the code from the URL, I proceed to send a ...

Accessing class fields from within an annotation in Typescript

Upon using the code snippet below: @Component({ props: { value: String }, mounted() { //Do something with `bar` this.bar = this.bar + " is now mounted"; } }) export default class Foo extends Vue { priv ...

How can I display an image before selecting a file to upload in Angular 9?

In the Angular project I'm working on, I currently have this code to enable file uploads: <input #file type="file" accept='image/*' (change)="Loadpreview(file.files) " /> Is there a way to modify this code so that ...

The Angular 16: Karma Test Explorer is reporting an error stating that afterAll, there is an Uncaught ReferenceError, as it

Angular 16: Encountering an error while attempting to install or run the Karma Test Explorer within VSCode. The specific error message is as follows: Failed to load tests - Test discovery failed: Browser Error - An error was thrown in afterAll Uncaught Re ...

Revolutionize Your Web Development with ASP.NET Core and Angular 2 Integration using Webpack

I have started a new ASP.NET Core 1.0.1 project and I am working on integrating Angular 2 from scratch with Webpack Module Bundler. My goal is to use Hot Module Replacement (HMR) through ASP.NET Core SpaServices in order to avoid browser reloads, but I am ...

Sources of the TypeScript library in WebStorm

I'm brand new to TypeScript. I decided to use WebStorm because I'm familiar with JetBrains tools. In other programming languages, I'm used to having a workflow that includes some kind of dependency management system like Maven, which allows ...

TypeScript: "The type is generic and can only be accessed for reading." - Error code 2862

Consider this sample JS function that requires type annotations: const remap = (obj) => { const mapped = {}; Object.keys(obj).forEach((key) => { mapped[key] = !!key; }); return mapped; }; I am attempting to add types using generics (in ...