How to send a value to a function in Angular from a different function?

Within my Angular Typescript file, I am working with two functions named data and lists. My goal is to pass the variable windows from the function data to the function lists.

However, when attempting to call the function lists, I encounter an error:

Cannot find name 'back'. Did you mean the instance member 'this.lists'?ts(2663)

UPDATE

After using this.list, the console logging of windows results in undefined

data(less: Mark, quick: HTMLTableDataCellElement) {
  const { a,b,c } = less;
  const windows = quick.innerText;
  lists(windows);     ------>>>>> Cannot find name 'lists'. Did you mean the instance member 'this.lists'

  this.value.newLevel({a, b, c windows}).subscribe(data => {
    this.processView(data);
  })
}

lists(windows){
 console.log(windows) ---> If I use this.lists the value is undefined
}

Answer №1

The list belongs to the same category,thus attempting to reach a function within an object. Rather than invoking list directly, it is necessary to use this.list

Answer №2

//This is the solution for your problem
function processData(mark: Mark, cellElement: HTMLTableDataCellElement) {
  const { x,y,z } = mark;
  const windowsData = cellElement.innerText;
  this.updateList(windowsData);

  this.fetchNewData({x, y, z, data: windowsData}).subscribe(result => {
    this.displayResult(result);
  })
}
updateList(data){}

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

What is the best way to activate ngModelChange for a custom input field?

I have developed a custom input component and here is the code: html: <input class='ctrl__counter-input' maxlength='10' type='text' [value]="counterValue" [ngModel]="counterValue" (ngModelChange)="onKey(in ...

Navigating a sortable list using jQuery

I have integrated the "sortable" script from on my web application to create a sortable list of items. While the sorting functionality works perfectly, I now need to update my server with the new order whenever changes are made. To capture the sorting ev ...

Forgot to include a semicolon in your code? If you attempted to parse SCSS using the regular CSS parser, give it another shot but this time with the

I am currently working on an Angular 14 project and one of my tasks involves changing the default font to our company's specific font. We are utilizing Angular material components and styles, so it is important for me to not only set the default font ...

Nuxt's axios is encountering difficulties in managing the server's response

Having just started working with Nuxt.js, I encountered an unusual issue. There is an endpoint in my backend API that allows users to reset their password by sending a token along with a new password. Although the request is being sent correctly and the s ...

Error: Unable to execute function on blog mapping

I am facing an issue with my app where it fails to detect objects. Every time the component in my app calls ".map", I encounter an error message. I have double-checked that index.js is passing props correctly. Can anyone explain why this problem is occurri ...

Replacing an array element by a specific index number in a React application

I am dealing with an array of [false,true,false,false,true] and I am looking to update the boolean values based on their index numbers. I have been trying to solve this problem in react, but haven't found a workable solution yet. this.setState({ ...

Implementing TypeScript with react-router-dom v6 and using withRouter for class components

Trying to migrate my TypeScript React app to use react-router-dom version v6, but facing challenges. The official react-router-dom documentation mentions: When upgrading to v5.1, it's advised to replace all instances of withRouter with hooks. Howe ...

Troubleshooting Tips for Resolving Problems with VueJS getElementById Bug

I'm currently working with a VueJS single File component that has the following template: <template> <div class="row"> <div class="col-md-12"> <div id="hottable"></div> < ...

Notify user with a Javascript alert if there are no search results found

I have developed a search index for Chicago employees and want to create an alert if no matching records are found. However, I am struggling to determine the value that needs to be inserted in case of an empty result set. Ideally, upon submission of the fu ...

Express js routing issue ("Page Not Found")

Why do I receive a "Cannot GET /" message when I access my HTTP server at http://localhost:8000/? I am using Express JS for server-side routing and Angular for client-side. Some sources suggest that this error occurs because I haven't set a route for ...

Unlocking the API endpoints within nested arrays in a React project

{ [ "quicktype_id": 1, "quicktype": "Laptops", "qucik_details": [ { "type_name": "car", "type_img": "car_img" }, { "type_name": "van", "type_img": ...

Utilizing the power of Typescript in Express 4.x

I'm currently working on building an express app using TypeScript and here is what my code looks like at the moment: //<reference path="./server/types/node.d.ts"/> //<reference path="./server/types/express.d.ts"/> import express = requir ...

Is it possible in Angular.js to limit the visibility of a service to only one module or to a specific group of modules?

When working with Angular.js, the services declared on a module are typically accessible to all other modules. However, is there a way to restrict the visibility of a service to only one specific module or a selected group of modules? I have some service ...

Looking to center a title in React Navigation without interference from headerLeft?

I am using react navigation and trying to center the title in the header bar. However, it seems to be affected by the presence of headerLeft. When I disable headerLeft, the title centers perfectly. How can I achieve this without interference from other lef ...

Hide the div when hovering occurs

I need a way to hide the 'sample' div when hovering over it and then show it again when the mouse moves away $('.secmenu').hover(function() { $('.sample').css('opacity', '0'); if ($('.secmenu&a ...

Ajax not functioning after submission of form

I currently have this code snippet: $('#my_form').submit(function () { setTimeout(function () { console.log('1'); $.ajax({ type: "GET", url: "/CorrectUrl/CorrectUrl", ...

Creating packaging for a node-webkit application

https://github.com/rogerwang/node-webkit/wiki/How-to-package-and-distribute-your-apps When I was packaging my node-webkit application for Windows using the instructions provided in the above link, I encountered a challenge. I could not figure out how to p ...

The data type 'number' cannot be assigned to type '(...items: any[]) => number'

Currently enrolled in an online Angular course with no prior programming knowledge. I am struggling to find the solution to my coding problem. What is the mistake and where should I look for it? Not using strict mode This is my HTML code: <button c ...

Is it possible to integrate a JavaScript library into the Vue prototype?

I've recently integrated ProgressBar.js library into my app, which is built using vue and laravel with laravel mix. After installing ProgressBar.js via npm install, I am unsure how to incorporate it into my .vue files. I'm considering adding it t ...

Different tsconfigs assigned to various directories

In my project, I am using Next.js with TypeScript and Cypress for E2E tests. The challenge I am facing is configuring tsc to handle multiple configs for different folders. The tsconfig.json file in the project root for Next.js looks like this: { "c ...