Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 09:24
    dwb-Sylar starred angular/angular
  • 09:23
    bougnat12 commented #39241
  • 09:12
    lheido starred angular/angular
  • 09:06
  • 09:05
    petebacondarwin commented #39642
  • 09:02
    petebacondarwin commented #39642
  • 08:51
    petebacondarwin commented #20419
  • 08:48
    yusufgedik commented #39642
  • 08:47
    StefanKern edited #39754
  • 08:47
    StefanKern edited #39754
  • 08:46
    petebacondarwin commented #20419
  • 08:44
    StefanKern opened #39754
  • 08:38
    kursatsaka commented #39642
  • 08:33
    petebacondarwin commented #39751
  • 08:32
    petebacondarwin synchronize #39751
  • 07:21
    ishkurko starred angular/angular
  • 07:02
    abdurrahmanyildirim starred angular/angular
  • 06:59
    Travis GistIcon/angular (usernamealreadyis-patch-100000000) errored (769)
  • 06:38
    shadow0162 starred angular/angular
Aubrey Quinn
@aubrey-fowler
@jorrit-wehelp oh ok, can you provide more details?
Jorrit
@jorrit-wehelp
often use things like combineLatest(balanceId$, year$).pipe(switchmap(([id, year]) => getBalance(id, year) )).... makes it nice and 'reactive'
the balanceId$ and year$ are observable, with some initial value and using form/user event events to update their value
Aubrey Quinn
@aubrey-fowler
How would you link the year observable to the view? e.g. in our component we'd have this.year$ = Observable(2020);
Jorrit
@jorrit-wehelp
hmm, depends if there's some source (e.g. often there's a state database). But if not, something like a new BehaviorSubject(2020) or this.userClick$.pipe(reduce((acc, cur) => cur - 1, 2020)) could work
again, reduce just as a quick example, probably needs more logic to limit the actual number :)
But also, one would often store/cache the last selected year, (or put it in the URL query param), so back/forward navigation works
matrixbot
@matrixbot
emotionalplant Hei, I have an issue where my bottom toolbar isn't visibly on mobile due to the address bar cutting into the height of the page. It only appears once user scrolls to bottom and address bar disappears. How would I go about detecting when the address bar is visible and when not?
Aubrey Quinn
@aubrey-fowler
Hi all, I know it's probably not the best approach but how can I pass in 2 objects into a template? e.g.
    <RadPieChart allowAnimation="true" *ngIf="balanceInfo$ | async as data">
        <PieSeries
            tkPieSeries
            selectionMode="DataPoint"
            expandRadius="0.4"
            outerRadiusFactor="0.7"
            valueProperty="value"
            categoryProperty="caption"
            legendLabel="Brand"
            items="{{ ...data.currentBalance, ...data.taken }}"
        >
        </PieSeries>
I want an array of objects
Dave Bush
@DaveMBush

@aubrey-fowler seems like what you want is:

[items]="[data.currentBalance, data.taken]"

unless I'm missing something

You need the brackets around items so that it will evaluate the righthand side and you need the brackets around currentBalance and taken to make it an array. Not sure why you thought you needed the spread operators.

Shekhar Ramola
@shekharramola
I have a firebase cloud function whose response I want to cache using rxjs share replay
is it possible?
public getAllProducts(limit, lastSortValue): Observable<any> {
    const onCallFunction = this.fns.httpsCallable('onFetchProduct');
    console.log(onCallFunction({ limit, lastSortValue }));
    // this.product$ = onCallFunction({ limit, lastSortValue })).pipe(

    // );
    return onCallFunction({ limit, lastSortValue });
  }
Victor Aprea
@vicatcu
Hey all, I'm using Cypress to do E2E testing on my Angular app
Cypress sometimes interacts with the app too quickly and I'm looking for a way to ensure that Angular has stabilized and attached all its event handlers before the test starts clicking stuff
with Cypress it's possible to do all sorts of clever things like spying on the DOM API and what not as described here: https://www.cypress.io/blog/2018/02/05/when-can-the-test-start/
but I'm struggling to think of a way to know that my app is ready all the way down to the bottom of the component tree and that all the data has flowed to its endpoints
does anyone have any suggestions as to how to do this robustly?
decorating my root level component with a class that is applied by ngAfterViewInit was one thing I thought of trying, but the more I think about it that is a pretty weak assertion of readiness
SAGO
@SAGOlab

Hi there, I wish to move some module.forRoot() inside a feature module, but I want to save the forRoot property. A practical example:

OAuthModule.forRoot({
      resourceServer: {
        sendAccessToken: true
      }
    }),

the module above is possible to move in a feature module and than import the feature module in app.module?

Shekhar Ramola
@shekharramola

I have this method, which is basically a method which call server for pagination data.. how to cache it?

this is my snippet

/**
   * fetch the number of products with last fetched products
   *
   * @param {number} limit
   * @param {string} startAt
   * @returns {Observable<Product>}
   * @memberof StoreService
   */
  public getAllProducts(limit, lastSortValue): Observable<Product[]> {
    this.product$ = this.http
      .post(`${environment.apiBaseUrl}/onFetchProduct`, { limit, lastSortValue })
      .pipe(
        shareReplay({ bufferSize: 1, refCount: true }),
        catchError(error => captureException(error))
      ) as Observable<Product[]>;
    return this.product$;
  }
L Suarez
@lsuarez5280

So in NG10, I've got three button elements separated by line breaks in source, such as:

<button />
<button />
<button />

But as far as I can ascertain, Ivy renders them more like:

<button /><button /><button />

which results in no single whitespace text element between these buttons. Is there something that I can configure to get this to behave more in line with what would be expected of HTML markup?

L Suarez
@lsuarez5280
Seems to do it.
N.S. Cutler
@godenji
What's the standard way of disabling component caching for urls of the form /foo and foo?bar=baz? Seems like the default behavior caches first access to foo component (regardless of url with/without querystring) and ignores any change in url state thereafter.
N.S. Cutler
@godenji
Ah, needed to lean on this.route.queryParams observable + subscribe rather than snapshot. Problem solved...
Shekhar Ramola
@shekharramola
if I have this/ this.products$ = this.getProducts(limit, lastSortValue);
where
getProducts(limit, lastSortValue) {
    const queryParams = {
      limit,
      lastSortValue
    };
    this.products$ = this.http
      .get(`${environment.apiBaseUrl}/onFetchProduct`, { params: queryParams })
      .pipe(
        shareReplay(1)
      );
    this.products$.subscribe(response => {
      console.log(response);
      this.products = this.products.concat(response.data.products);
      console.log(this.products);
    });

    return of(this.products);
  }
will this.products$ wait so that I can return the result?
Ahsanbaloch
@Ahsanbaloch

Hi!

I want to use form for add and update value. how can I do that? what should be the method for update?
currently html file code is for addition is

  <form [formGroup]="form" (ngSubmit)="Create_Faculty_Accounts()" class="mb-2">
        <table class="table text-center">
          <tbody>
            <tr>
              <td>
                <div class="form-group mb-2">
                <label for="Name" class=" mx-sm-3">Name:</label>
                <input type="text" formControlName="Name" class="form-control"   [ngClass]="{ 'is-invalid': submitted && f.Name.errors }"/>
                          <div *ngIf="submitted && f.Name.errors" class="invalid-feedback">
                            <div *ngIf="f.Name.errors.required">Name is required</div>
                        </div>
              </div>
            </td>
              <td>
                <div class="form-group mb-2">
                <label  class="mx-sm-3">Email:</label>
                <input type="email" formControlName="Email" class="form-control"  [ngClass]="{ 'is-invalid': submitted && f.Email.errors }"/>
                           <div *ngIf="submitted && f.Email.errors" class="invalid-feedback">
                            <div *ngIf="f.Email.errors.required">Email is required</div>
                        </div>
              </div>
            </td>
              <td><div class="form-group mb-2">
                <label for="email" class=" mx-sm-3">Designation</label>
                <input type="text" formControlName="Designation"  class="form-control"  [ngClass]="{ 'is-invalid': submitted && f.Designation.errors }" #Designation/>
                            <div *ngIf="submitted && f.Designation.errors" class="invalid-feedback">
                              <div *ngIf="f.Designation.errors.required">Designation is required</div>
            </div>
              </div>
            </td>
            </tr>
            <tr>
              <td>
                <div class="form-group mb-2">
                  <label  class="mx-sm-3">Contact:</label>
                  <input type="tel" formControlName="Contact" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.Contact.errors }"/>
                    <div *ngIf="submitted && f.Contact.errors"  class="invalid-feedback">
                      <div *ngIf="f.Contact.errors.required">Contact is required</div>
                  </div>
                </div>
              </td>
        <td>
          <ng-template
          *ngIf="techer();then ifShow; else ifNotShow">
        </ng-template>
        <ng-template #ifShow>
          <div class="form-group mb-2">
            <label for="sel1" class="mx-sm-3"> Subjects: </label>
            <select class="form-control" formControlName="Subjects" id="sel1"  [ngClass]="{ 'is-invalid': submitted && f.Subjects.errors }" >
              <option *ngFor="let account of subjects" [value]="account.Sub_Title">{{ account.Sub_Title }}</option>
            </select>
              <div *ngIf="submitted && f.Subjects.errors" class="invalid-feedback">
              <div *ngIf="f.Subjects.errors.required">Subject is required</div>
          </div>
          </div>
        </ng-template>

        <ng-template #ifNotShow>

          <div class="form-group mb-2">
            <label for="sel1" class="mx-sm-3"> Subjects: </label>
            <input type="tel" formControlName="Subjects"  class="form-control" [ngClass]="{ 'is-invalid': submitted && f.Contact.errors }" [attr.disabled]=true [ngModel]="dflt"/>

            <div *ngIf="submitted && f.Subjects.errors" class="invalid-feedback">
              <div *ngIf="f.Subjects.errors.required">Subject is required</div>
          </div>
          </div>

        </ng-template>

              </td>
              <td>
                <div class="form-group mb-2">
                  <label  class="mx-sm-3">Address:</label>
                  <input type="text" formControlName="Address" class="form-control"    [ngClass]="{ 'is-invalid': submitted && f.Address.errors }"/>
                    <div *ngIf="submitted && f.Address.error

ts file for addition is

 private Create_Faculty_Accounts() {
    // console.log(this.form.value);
    this.accountService
      .createfaculty(this.form.value)
      .pipe(first())
      .subscribe({
        next: () => {
          this.alertService.success('Account created successfully', {
            keepAfterRouteChange: true,
          });
          this.router.navigate(['../'], { relativeTo: this.route });
        },
        error: error => {
          this.alertService.error(error);
          this.loading = false;
      }
      });
  }

Update form html code is

table class="table table-striped">
          <thead>
              <tr>
                <th style="width:30%">Id</th>
                  <th style="width:30%">Name</th>
                  <th style="width:30%">Email</th>
                  <th style="width:30%">Designation</th>
                  <th style="width:10%"></th>
              </tr>
          </thead>
          <tbody>
              <tr *ngFor="let fclt of faculty">
                <td> {{fclt.id}} </td>
                  <td>{{fclt.Name}} </td>
                  <td>{{fclt.Email}}</td>
                  <td>{{fclt.Designation}}</td>
                  <td style="white-space: nowrap">
                      <!-- <a routerLink="edit/{{fclt.id}}" class="btn btn-sm btn-primary mr-1">Edit</a> -->
                      <button (click)="deletefaculty(fclt.id)" class="btn btn-sm btn-danger btn-delete-account" [disabled]="fclt.isDeleting">

              <span *ngIf="fclt.isDeleting" class="spinner-border spinner-border-sm"></span>
              <span *ngIf="!fclt.isDeleting">Delete</span>
                      </button>
                  </td>
              </tr>
              <tr *ngIf="!faculty">
                  <td colspan="4" class="text-center">
                      <span class="spinner-border spinner-border-lg align-center"></span>
                  </td>
              </tr>
          </tbody>
      </table>

i am using ts method for upate is given below

 private updateFaculty() {
    this.accountService.updatefaculty(this.id, this.form.value)
        .pipe(first())
        .subscribe({
            next: () => {
                this.alertService.success('Update successful', { keepAfterRouteChange: true });
                this.router.navigate(['../../'], { relativeTo: this.route });
            },
            error: error => {
                this.alertService.error(error);
                this.loading = false;
            }
        });
}
Johan
@JohanurRahman_twitter
Hello, I am having some trouble implementing JWT refresh token . Can anyone help?
Supun Silva
@supunlk
hi guys How can i load parent router(component) till child resolves data?
Antoniossss
@Antoniossss
Hi all, do you now how to detect that user typed in NON NUBER VALUE when using MatFormField and <input type="number"/>?
I would expect to have proper key in control.errors - buts it is empty - the value is only set to null in case of non number input - but is in conflict with required validator. I cannot distinguish those 2 scenarios while I would like to - to show dedicated error message in both cases
jcapil-ictdu
@jcapil-ictdu
does anyone use gridster2?
faguilera85
@faguilera85
Anyone can tell me why this doesn't work?
this.componentRef.location.nativeElement.children[0].scrollTop = position;
It's not scrolling the div
faguilera85
@faguilera85
cri cri, cri cri ...
SAGO
@SAGOlab
@faguilera85 eny error in console?
faguilera85
@faguilera85
nope
bchiremath1
@bchiremath1
Hi...I built an android app using Ionic Angular (I built a web app then created android app using ionic), but when I am trying to submit the app to the Google Store, it is getting rejected saying - "We have detected that your app generates a webview of a website without additional functionality".
Can you help me with this?
3 replies
Thanks
santoshfurtado
@santoshfurtado

Hi All, I am facing one issue with Angular with SSR.
Can anyone help me to understand what could be the issue here?

I have called one function on APP_INITIALIZER "appConfig.load()"
This function is called multiple times in server.ts file.
Is this the correct behavior?

I would like to have few API calls in this function and execute on the server before the application loads but this leading to multiple duplicate calls on the server.

app.Module.ts

export function initializeApp(appConfig: AppConfig) {
  return () => appConfig.load();
}

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule.withServerTransition({ appId: 'serverApp' }),
    AppRoutingModule,
    // TransferHttpCacheModule,
    BrowserTransferStateModule,
    HttpClientModule,
    BrowserAnimationsModule,
    ReactiveFormsModule,
    NgImageSliderModule
  ],
  providers: [
    AppConfig,
    { provide: APP_INITIALIZER, useFactory: initializeApp, deps: [AppConfig], multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: ResponseInterceptor, multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

app.server.module.ts

@NgModule({
  imports: [
    AppModule,
    ServerModule,
    ServerTransferStateModule,
  ],
  providers: [
    {
      provide: HTTP_INTERCEPTORS,
      useClass: UniversalInterceptor,
      multi: true
    }
  ],
  bootstrap: [AppComponent],
})
export class AppServerModule { }

server.ts logs
server.ts--> /
appConfig.load();
server.ts--> /assets/images/favicon.ico
appConfig.load();
server.ts--> /assets/products/Demo_Make%20Fun%20Happen_Card_Front.jpg
appConfig.load();
server.ts--> /assets/products/Demo_We%20Make%20Fun%20Happen_Card_Front.jpg

Gaetan Paucot
@gpaucot

Hi all, I am building a library that contains a lazy-loaded route like this:

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { MyComponent } from './components/my.component';

const routes: Routes = [
    { path: '', component: MyComponent },
    { path: 'books', loadChildren: () => import('./books/books.module').then((m) => m.BooksModule) },
];

@NgModule({
    imports: [RouterModule.forChild(routes)],
    exports: [],
})
export class MyRoutingModule {}

When I compile it with ng build --prod, I get this:
[...] Metadata collected contains an error that will be reported at runtime: Lambda not supported.
Anyone met the same issue ?