I am looking to update my table once I have closed the modal in Angular

I am facing an issue with refreshing the table in my component using the following function:

this._empresaService.getAllEnterprisePaginated(1);
. This function is located in my service, specifically in the modal service of the enterprise component.

CODE for the enterprise component

createEnterprise() {
        this._empresaService.createNewEnterprise(this.imagenSubir, this.enterprise_name)
        .then((resp: any) => {
            resp = JSON.parse(resp);
            if(resp.out == 1) {
                this.toastr.error('La empresa ' + this.enterprise_name + ' ya se encuentra registrada en el sistema', 'Error!', {
                    positionClass: 'toast-bottom-left',
                    progressBar: true
                });
                return;
            } else {
                this.toastr.success('La empresa ' + this.enterprise_name + ' fue creada exitosamente', 'Empresa creada!', {
                    positionClass: 'toast-bottom-left',
                    progressBar: true
                });
                this.cerrarModal();
                // this._empresaService.getAllEnterprisePaginated(1);
                // for (let i = 0; i < this._empresaService.allEnterprise.length; i++) {
                //  var emp : Enterprise = this._empresaService.allEnterprise[i]

                // }
            }
        });

    }

CODE for the ENTERPIRSE MODAL SERVICE

getAllEnterprisePaginated(init_page: any = 1) {
        let page = {init_page: init_page}
        let url = URL_SERVICIOS + '/getallenterprise';
        return this.http.post(url, page)
        .pipe(map((resp: any) => {
            this.allEnterprise = resp.recordset
            return resp;    
        }));
    }

The function I added is not functioning as expected.

Answer №1

corporate module

this._companyService.getAllCompanyItems(1).subscribe(response =>{
for (let i = 0; i < response; i++) {
       var comp : Company = response[i];
   }
})

There is no data coming from this._companyService.allCompany console.log(this._companyService.allCompany);

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

Encountering a TypeError while working with Next.js 14 and MongoDB: The error "res.status is not a function"

Currently working on a Next.js project that involves MongoDB integration. I am using the app router to test API calls with the code below, and surprisingly, I am receiving a response from the database. import { NextApiRequest, NextApiResponse, NextApiHandl ...

Can a type be established that references a type parameter from a different line?

Exploring the Promise type with an illustration: interface Promise<T> { then<TResult1 = T, TResult2 = never>( onfulfilled?: | ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ...

Integrate a JS file into my Angular 4 project

For one of my components, I am looking to implement a specific effect: https://codepen.io/linrock/pen/Amdhr Initially, I attempted to convert the JavaScript code to TypeScript, but faced challenges. Eventually, I decided to directly copy the JS file from ...

Express middleware generator function causing a type error

I recently implemented a function that takes a middleware function, wraps it in a try-catch block, and then returns the modified middleware function. tryCatch.ts import { Request, Response, NextFunction } from "express"; export default function ...

The Datepicker label in Angular (^16.0.0) Material (^16.1.0) is floating at an unexpectedly high position

I'm struggling to implement a mat-datepicker in my Angular page because the label is floating too high. When I select a date, the label ends up getting pushed under the top bar of the page. I can't figure out what's causing this issue; help ...

Is there a way to selectively deactivate the routerLink attribute?

I am facing a challenge in my Angular 2 project where I am unable to disable the routerLink functionality successfully. Despite trying to intercept the click event on the 'click' event with 'event.preventDefault()' and 'event.stopP ...

Angula 5 presents a glitch in its functionality where the on click events fail

I have successfully replicated a screenshot in HTML/CSS. You can view the screenshot here: https://i.stack.imgur.com/9ay9W.jpg To demonstrate the functionality of the screenshot, I created a fiddle. In this fiddle, clicking on the "items waiting" text wil ...

Convert checkbox choices to strings stored in an array within an object

I have a intricate object structure JSON{ alpha{ array1[ obj1{}, obj2{} ] } } In addition to array1, I need to include another array: array2 that will only consist of strin ...

Exploring Angular2: A demonstration showcasing concurrent http requests (typeahead) using observables

Currently, I am working on several cases within my app that require the following sequence of events: Upon triggering an event, the desired actions are as follows: List item Check if the data related to that context is already cached; if so, serve cache ...

My goal is to prevent users from using the Backspace key within the input field

Let's say we want to prevent users from using the backspace key on an input field in this scenario. In our template, we pass the $event like so: <input (input)="onInput($event)"> Meanwhile, in our app.component.ts file, the function ...

What is the correct method for caching fonts within an Angular application?

In the process of developing a web application similar to photoshop-minis using Angular, one key aspect I am focusing on is reducing load times. Particularly when it comes to fonts, as not all necessary fonts are available through Google Fonts. Instead of ...

Utilize a string to access and sort the properties of a class in TypeScript

Let's discuss a simple problem involving objects in Javascript. Take for example an object like this: var obj={ par1:'value1', par2:'value2' } In JavaScript, we can access the values like obj['par1']. Now, the q ...

Angular 5's external JavaScript library

After thoroughly researching this subject, I find myself still lacking comprehension. An example may be the key to understanding. As a newcomer to Angular, my goal is to create a mathematical application for mobile using Ionic. Despite investing two weeks ...

Building a TypeScript Rest API with efficient routing, controllers, and classes for seamless management

I have been working on transitioning a Node project to TypeScript using Express and CoreModel. In my original setup, the structure looked like this: to manage users accountRouter <- accountController <- User (Class) <- CoreModel (parent Class o ...

Utilizing Angular 9's inherent Ng directives to validate input components within child elements

In my current setup, I have a text control input component that serves as the input field for my form. This component is reused for various types of input data such as Name, Email, Password, etc. The component has been configured to accept properties like ...

What is the proper way to structure a React component class without any props?

When working with Typescript in a React project, the top level component typically does not receive any props. What is the recommended approach for typing this scenario? I have been using the following coding structure as a template, but I am curious if t ...

Can you explain the meaning of `((prevState: null) => null) | null`?

Upon encountering this code snippet: import { useState } from "preact/hooks"; export default function Test() { const [state, setState] = useState(null); setState('string'); } An error is thrown: Argument of type 'string' ...

Using JQuery within Angular 4 is a valuable tool for enhancing the functionality

As a newcomer to Angular, I am experimenting with using jQuery alongside Angular 4. In my search for information, I stumbled upon this question on Stack Overflow. Inside the question, there was an example provided that can be found here. However, when att ...

Using TypeScript to style React components with the latest version of Material UI, version

Styled typography component accepts all the default typography props. When I include <ExtraProps> between styled() and the style, it also allows for extra props. const StyledTypography = styled(Typography)<ExtraProps>({}) My query is: when I r ...

What is the best method for sharing templates and logic in VUE?

Two separate components with shared logic and template, making it appear as though one is extending the other. Think of Drop and Pick components in this manner: // pick.js import Vue from 'vue' import Component from 'vue-class-component& ...