[Solved] Persist class property Angular 5

You could either use a Service or localStorage/Session Storage for Persisting Data. localStorage and sessionStorage accomplish the exact same thing and have the same API, but with sessionStorage the data is persisted only until the window or tab is closed, while with localStorage the data is persisted until the user manually clears the browser cache … Read more

[Solved] Angular 2 onclick add new item in array

You have a few problems… You have this interface: interface Joke{ id: number; value: string; } what you are receiving is much more properties, so you’d need to pick the properties you want: getRandomJokes(){ return this.http.get(‘https://api.chucknorris.io/jokes/random’) .map(res => res.json()); // pick the properties you want/need .map(joke => <Joke>{id: joke.id, value: joke.value}) } Then you have … Read more

[Solved] how to convert Java Instant for showing Date in the angular client side? [closed]

Angular have built in date pipe setDateTime(dateTime) { let pipe = new DatePipe(‘en-US’); const time = pipe.transform(dateTime, ‘mediumTime’, ‘UTC’); const date = pipe.transform(dateTime, ‘MM/dd/yyyy’, ‘UTC’); return date + ‘ ‘ + time; } html <span>{{dateTime| date:’MM/dd/yyyy’ : ‘UTC’}}</span> 1 solved how to convert Java Instant for showing Date in the angular client side? [closed]

[Solved] Error: Type ‘string’ is not assignable to type ‘Subscription’. How can I convert/parse this?

You aren’t declaring the variable in the function but straight up initializing it with the subscription. Instead you need to declare it. Try the following private getMaxSeconds() { let maxSeconds: string; this.configurationRemoteService.get(‘MAX_SECONDS’).subscribe( config => { maxSeconds = config.value; }, err => { } ); return maxSeconds; // <– WRONG! Will return `undefined` And you cannot … Read more

[Solved] Loop json objects keys to add Google Maps data

The issue with point variable beacause it is an array of point details. You have to add all markers one by one and here I am indicating the exact place where you have the issue. let marker: Marker = this.map.addMarkerSync({ title: ‘Ionic’, icon: ‘blue’, animation: ‘DROP’, position: this.point // issue in here because trying to … Read more

[Solved] PLS HELP ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: ‘r2’ Error: Cannot match any routes. URL Segment: ‘r2’

<ion-item *ngFor=”let recipe of recipes” [routerLink]=”[“https://stackoverflow.com/”, recipe.id]”> [routerLink]=”[“https://stackoverflow.com/”, recipe.id]” means you’re redirecting to the root route. But your expected route is a child of the route. Use this instead : [routerLink]=”recipe.id” 0 solved PLS HELP ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: ‘r2’ Error: Cannot match any routes. URL Segment: … Read more

[Solved] How can I use if, else if in Angular2

Wait it’s simpler then that. In template: <div *ngIf = “name == ‘a'”>if a</div> <div *ngIf = “name == ‘b'”>if b</div> <div *ngIf = “name == ‘c'”>if c</div> edit If you want to make it dynamic do *ngFor let name of names and do ngIf on {{name}} <div *ngFor=”let name of names”> <p *ngIf = … Read more

[Solved] Transfer data between angular components using @input and @output [duplicate]

you just need use property binding to pass the data to child component settings component template <app-user-profile [data]=”userSettings”></app-user-profile> userProfile.ts @Input() data:any; now the value from the userSettings will pass to the data property. 15 solved Transfer data between angular components using @input and @output [duplicate]

[Solved] Ionic5/Angular – Error trying to diff ‘[object Object]’. Only arrays and iterables are allowed

I’d try something like this, As long as the querySnapshot returns array of storedData without any nested objects, you can set it directly if not you have to read it through the correct entry from the response structure and read the values from the list accordingly in your HTML template fetchBookings() { this.afs .collection(‘user’) .doc(this.userId) … Read more

[Solved] how to deal with multiple possible null on angular template

Dealing with null property paths at Angular 1. Using safe navigation operator: The safe navigation operator (?) means that the employer field is optional and if undefined, the rest of the expression should be ignored. <p>Employer: {{employer?.companyName}}</p> 2. Using ngIf Removes or recreates a portion of the DOM tree based on the showSection expression. <section … Read more

[Solved] What’s the best way to add/remove dynamically Form Array item?

You should call push method on formArray control. Since you are pushing new FormGroup inside normal array underlaying FormGroup is not get updated. addFarina() { let farineForm = this.form.value.ingredienti.farine; let farineFormControls = this.form.get(‘ingredienti’).get(‘farine’) as FormArray; if (farineForm.length < 4) { const farina = this.fb.group({ quantita: [null, [Validators.required]], nome: [”] }) farineFormControls.push(farina); } console.log(this.form.get(‘ingredienti’).value); } Now … Read more

[Solved] Three captions of same size inside of a div element

Here is what u needed. .tabs label { padding: 10px 20px; border-left: 1px solid #ccc; border-right: 0; float: left; } label.selected { background: #ccc; } .tabs label:first-child { border-left: 0; } .tabs { margin: 10px; display: inline-block; border: 1px solid #ccc; border-radius: 20px; overflow:hidden; } <div class=”tabs”> <label class=”selected”> Label 1 </label> <label> Label 2 … Read more