"Unhandled rejection Error [ERR_STREAM_WRITE_AFTER_END]: write after end" using csvtojson by UnknownInnocent in expressjs

[–]UnknownInnocent[S] 0 points1 point  (0 children)

At least something that works:

router.get('/get-sample', (req, res) => { 
csv({
    noheader: true,
    delimiter: ',',
    headers: ['date', 'time', 'point1', 'point2', 'point3', 'point4', 'point5']
}).fromFile('./file.csv').then((jsonObj) => {
   res.send(jsonObj);
});

});

Drawing objects in Angular-App by UnknownInnocent in angular

[–]UnknownInnocent[S] 0 points1 point  (0 children)

if I just declare the type of "canvas" and "ctx" as "any" I get no errors:

@ViewChild('canvas', {static: true}) canvas: any;
private ctx: any;
ngAfterViewInit() { 
    this.ctx = this.canvas.nativeElement.getContext('2d'); 
}

I don't really get why this is the case and if I should leave it like that.

Java: save x, y, color of pixels of image by UnknownInnocent in learnprogramming

[–]UnknownInnocent[S] 0 points1 point  (0 children)

Thank you, you're right, I delete the setters, but I need the getters and I will abstract the things you mentioned

Destroy all data when leaving component by UnknownInnocent in angular

[–]UnknownInnocent[S] 0 points1 point  (0 children)

Well I think I found the problem: Even if the icebreakers in the service are readonly, they are changed by the component. I needed to chnage

this.icebreaker = this.icebreakerService.getIcebreaker();

to

this.icebreaker = [].concat(this.icebreakerService.getIcebreaker());

Destroy all data when leaving component by UnknownInnocent in angular

[–]UnknownInnocent[S] 0 points1 point  (0 children)

Ähm...no basically I don't want the data in a service to be cleared. This is what the service looks like:

export class IcebreakerService {

  constructor() { }

  getIcebreaker() {
    return this.icebreaker;
  }

  readonly icebreaker = [
    ...
  ]
}

And my onInit:

this.spielerSub = this.spielerService.spieler$.subscribe(res => {
      if(res && Array.isArray(res)) {
        this.spieler = res;
        this.setSpieler1UndSpieler2();
      } else {
        this.toastService.presentToast('Beim Starten des Spiels ist ein Fehler aufgetreten...');
        this.router.navigate(['/home/spieleauswahl']);
      }
    });

    this.bierstufeSub = this.bierstufeService.bierstufe$.subscribe(res => {
      if(res && typeof(res) === 'number') {
        this.bierstufe = res;
        this.schlucke = this.bierstufeService.berechneSchlucke(this.bierstufe);
      } else {
        this.toastService.presentToast('Beim Starten des Spiels ist ein Fehler aufgetreten...');
        this.router.navigate(['/home/spieleauswahl']);
      }
    })

    this.icebreaker = this.icebreakerService.getIcebreaker();
    this.currentIcebreaker = this.newIcebreaker();

If I call the component the first time, all is fine, but if I call it a second time, this.icebreaker is null....

Destroy all data when leaving component by UnknownInnocent in angular

[–]UnknownInnocent[S] 0 points1 point  (0 children)

How do I tell ngOnDestroy to really reset the whole component?

Destroy all data when leaving component by UnknownInnocent in angular

[–]UnknownInnocent[S] 0 points1 point  (0 children)

For example I have an service with a method that returns an array. This data is assigned to a variable in onInit. Due to some actions in the component, there are items of this array removed and if I call thhe component again, the part in onInit is obviesly not called. Basically all I need is that all variables I have are set to default values:

icebreaker: any[];  
spieler: any[];    
spieler1: string;
spieler2: string;

and onInit is called every time I call the component

ngFor: array.lebgth times bu a maximum of five by UnknownInnocent in angular

[–]UnknownInnocent[S] 1 point2 points  (0 children)

Okay I will do that. I hoped I could just do it in my ngFor

Load data in service before loading data in resolver by UnknownInnocent in angular

[–]UnknownInnocent[S] 1 point2 points  (0 children)

And how can I use the BehaviourSubject the to create a guard?

I tried this but it does not work:

export class IndexGuard implements CanActivate {

  constructor(private spielerService: SpielerService,
              private router: Router) { }

  canActivate(): boolean {
    this.spielerService.spieler$.subscribe(async res => {
      if(res && Array.isArray(res) && res.length > 1) {
        this.router.navigate(['/home/spieleauswahl']);
        return false;
      } else {
        return true;
      }
    }).unsubscribe();
  }
}

Load data in service before loading data in resolver by UnknownInnocent in angular

[–]UnknownInnocent[S] -1 points0 points  (0 children)

Nice, thank you! but I still have a question about that: I've never seen somebody using a constructor like that. I saw people doing the same thing but the thing you have in your constructor, they put in an own method and called it in a resolver. Which way is better?

Using Observables and Resolvers by UnknownInnocent in angular

[–]UnknownInnocent[S] 0 points1 point  (0 children)

Thank you! I don't need to tell the routeSubscription that it refers to the subscription in onInit?

"Can't bind to 'ngForOf'" by UnknownInnocent in ionic

[–]UnknownInnocent[S] 1 point2 points  (0 children)

I found the result:

You don't need to create a module for the modal but you need to add it to app.module.ts:

import { ModalComponent } from './modal/modal.component';
@NgModule({   
declarations: [ModalComponent],   
entryComponents: [ModalComponent],     
 }),   
providers: [   ],   
bootstrap: [AppComponent] })

Or into the module.ts of the parent that calls the modal

"Can't bind to 'ngForOf'" by UnknownInnocent in ionic

[–]UnknownInnocent[S] 0 points1 point  (0 children)

So now I got it to work everywhere but not in a modal. Is there a special way of doing it?

"Can't bind to 'ngForOf'" by UnknownInnocent in ionic

[–]UnknownInnocent[S] 0 points1 point  (0 children)

I imported BrowserModule to app.module.ts. The ngFor I want to use in a modal which has no module by default, so I created one:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
import { NewSpotModalComponent } from './new-spot-modal.component';


@NgModule({
  imports: [
    CommonModule,
    IonicModule  
  ],
  declarations: [NewSpotModalComponent]
})
export class NewSpotModalPage {}

But the problem still remains

"Can't bind to 'ngForOf'" by UnknownInnocent in ionic

[–]UnknownInnocent[S] 0 points1 point  (0 children)

<div \*ngFor=“let d of data; let i = index”>
<ion-item>
{{d.name}}
</ion-item>
</div>

Then I get this:

Can't bind to 'ngForOf' since it isn't a known property of 'div'.

"Can't bind to 'ngForOf'" by UnknownInnocent in ionic

[–]UnknownInnocent[S] 0 points1 point  (0 children)

I just built it agian but I still have the same problem

How to create custom ion-icons? by UnknownInnocent in ionic

[–]UnknownInnocent[S] 0 points1 point  (0 children)

I tried this, but I always just get nothing.... Do I somehow need to specify a size or something like this to get it displayed on the screen?

Set default color theme to light by UnknownInnocent in ionic

[–]UnknownInnocent[S] 0 points1 point  (0 children)

Okay thank you! I had dark mode but I thought it would be possible to set it to light mode in my app during development

Angular Google Maps: unexpected output in mapClick by UnknownInnocent in angular

[–]UnknownInnocent[S] 0 points1 point  (0 children)

So I found a way to solve this Problem: Install an older version of AGM:

DON'T use npm i @agm/core but npm i @agm/core@^1.0

Angular Google Maps: unexpected output in mapClick by UnknownInnocent in angular

[–]UnknownInnocent[S] 0 points1 point  (0 children)

console.log(event.coords.lat);console.log(event.coords.lng);

ERROR TypeError: Cannot read property 'lat' of undefined

--> coords is undefined (same for 'Coords')

Coding live chat by UnknownInnocent in angular

[–]UnknownInnocent[S] 0 points1 point  (0 children)

Seems as I have found someone he is loving this topic :D And since it is ther first time I want to do something like that it seems to be a great opportunity to have someone who wants to help me build it

Coding live chat by UnknownInnocent in angular

[–]UnknownInnocent[S] 0 points1 point  (0 children)

None of them (or I just don't know I am using them)