Questions tagged ngoninit

Explore the latest questions and answers asked by our top developers.

How to see fields in data (subscribe) in Angular

I want to choose the Objects that I want to put in the tasks array according to IdEmployee Im trying to display the content of data (in which there is the field "IdEmployee"), but when I display it, I can see : data.IdEmployee = undefined In the html file, I can see the entire array […]

By user123456
Published
Categorized as angular, ngoninit, subscribe Tagged , ,

How to make menuboard loaded after receiving response from app component

In my angular 6 application I make a service call within ngOnInit() of app component to receive the configuration details . After receiving the configuration I am storing it in local storage and Based on the configuration few modules will be hidden or shown in menuboard . But at times am getting response from both […]

By Ani
Published
Categorized as angular, ngoninit, service Tagged , ,

Cannot read property ‘forEach’ of undefined Angular

my code ngOnInit(): void { this.posts = this.service.getPosts(); this.Posts.forEach((a:any)=>{ Object.assign(a,{total:a.price}); }); } Why am I getting "Cannot read property ‘forEach’ of undefined" error in console Source: Angular Questions

By unknown
Published
Categorized as angular, foreach, ngoninit Tagged , ,

Why ngOnInit is recharge

why ngOnInit reloads after the data in firebase is modified Here is the line of code who make ngOnInit reload this.db.database.ref(“clients/” + this.user.num + “/mots_cles”+motCleOrder).set(mot.toLowerCase()); Source: Angular Questions

By TomTom
Published
Categorized as angular, ngoninit Tagged ,

angular audio play on ngoninit not working

html code: <audio id="notification" src="../assets/audio/notification.mp3" autoplay="true" muted="muted"></audio> ts code: let audioPlayer = <HTMLAudioElement> document.getElementById(‘notification’); audioPlayer.muted = false; audioPlayer.play(); I am getting error play() failed because the user didn’t interact with the document first. Source: Angular Questions

By Pattinson Mj
Published
Categorized as angular, audio, html, javascript, ngoninit Tagged , , , ,

How to call ngOnit function of a component from another component in Angular

So I have a component called "CreateBugsViewComponent" in this component I wat to use ngOnit function of my another component which is "ProjectBugsComponent" So how can I do this the code for "CreateBugsViewComponent" is written below: import { HttpClient } from ‘@angular/common/http’; import { Component, OnInit } from ‘@angular/core’; import { FormControl, FormGroup, Validators } […]

How to handle undefined when passing data with Input in Angular?

A component colled with passing value with Input(): <app-available-modal [good]="’test’"></app-available-modal> The component looks like: @Component({ selector: ‘app-available-modal’, templateUrl: ‘./available-modal.component.html’, styleUrls: [‘./available-modal.component.scss’] }) export class AvailableModalComponent implements OnInit { @Input() good: TyreGoodModelTemp; constructor() { console.log(this.good); } ngOnInit(): void { console.log(this.good); } } I expect "test" and "test" output in the console. And the console.log from ngOnInit() […]

By mr blond
Published
Categorized as angular, binding, input, javascript, ngoninit Tagged , , , ,

How to pass parameters in Angular between pages

My Node.js backend returns the AWS Cognito tokens as JSON which are received in my Angular login Component. I wish to open my dashboard and pass the received tokens in my login.component.ts function I do: this.router.navigate([‘/dashboard’, { tokens: data }]); before sending the data I print it to the console and it looks fine in […]

By Kukula Mula
Published
Categorized as angular, ngoninit, parameters, routes Tagged , , ,

Angular: in ngOnInit() My rxjs Fucntion dont run when I reload my component

My Angular application has the following components. 1 MessengerService. This service I am using to send/get data to other components using RxJs. The code of the service is here. import { Injectable } from ‘@angular/core’; import {ReplaySubject, Subject} from ‘rxjs’; @Injectable({ providedIn: ‘root’ }) export class MessengerService { _Subject = new ReplaySubject(1); constructor() { } […]

By Abdul Rehman
Published
Categorized as angular, ngoninit, rxjs Tagged , ,

List of checkboxs keep initial state after changing page

Am using angular 9 and i have a list of checkboxes that need to be set true by default to list of some data. Upon unchecked of one those checkboxes it should display certain data. The problem i encountered is that when i have unchecked and try to navigate to another page , those checkboxes […]

By snoopy
Published
Categorized as angular, checkboxlist, ngoninit, typescript Tagged , , ,
1 2 3 5

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq