Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 04:03
    Nisarga-Developer starred angular/angular
  • 03:15
    ramthir synchronize #44359
  • 03:13
    ramthir ready_for_review #44359
  • 02:45
    ngbot[bot] milestoned #44375
  • 02:45
    ngbot[bot] milestoned #44375
  • 02:45
    google-cla[bot] labeled #44375
  • 02:45
    AndrewKushnir review_requested #44375
  • 02:45
    AndrewKushnir labeled #44375
  • 02:45
    AndrewKushnir labeled #44375
  • 02:45
    AndrewKushnir labeled #44375
  • 02:45
    AndrewKushnir labeled #44375
  • 02:45
    AndrewKushnir opened #44375
  • 02:13
    dgp1130 commented #44374
  • 01:58
    dgp1130 synchronize #44374
  • 01:57
    google-cla[bot] labeled #44374
  • 01:57
    dgp1130 review_requested #44374
  • 01:57
    dgp1130 opened #44374
  • 01:57
    dgp1130 review_requested #44374
  • 01:57
    dgp1130 labeled #44374
  • 01:52
    zxhggjj starred angular/angular
Ryan Pierce
@piercers
@DrewMoody const helper: ComparerFn<MyCustomType> = (a, b) => {}, I think.
DrewMoody
@DrewMoody
That's one thing I tried. It doesn't work, says T doesn't exist... So it wants T to be defined sooner. I am just not sure where you'd define the generic in that event. Maybe it's a quirk of TS. Or maybe I have to give it a default of any? I don't know. I can work around it
3 replies
DrewMoody
@DrewMoody
One more... Is there any way to do something like this?
// way to define prop as being a keyof T that has a value of string?
function stringPropertyComparerFn<T, K extends keyof T>(a: T, b: T, prop: )
Ryan Pierce
@piercers
@DrewMoody Not sure about that one -- but it sounds cool. I've tried to do that recently as well and got the impression function overloads were the way to achieve that.
Gabriel Araujo
@gabrielaraujof
Hello, does anyone know if there is any possibility of getting an undefined NavigationTransition when router is trying to apply redirects? I'm getting this error: TypeError: Cannot read property 'extractedUrl' of undefined. Looking at the router source code (https://github.com/angular/angular/blob/master/packages/router/src/router.ts#L583) it seems like it's getting the navigation object as undefined inside the applyRedirects function. But how is that possible? I've read the source code many times already trying to figure out how could it be undefined but I haven't understood.
Could anyone help me to crack it out?
freshdev1
@freshdev1
can anybody go through this stackblitz example and let me know what wrong I am doing with FormArray:
https://stackblitz.com/edit/angular-q9wmok-idtrup?file=src%2Fapp%2Fprop-array-add.component.ts
idea is to remove the old array controls, objects and insert a new one with a value
it won't let me do it.
I am using a RxWeb library, but its just a wrapper above the Angular's own Forms module. If anyone can get it to work with Angular's FormArray it would be great.
Oh - sorry, I misread - one sec...
freshdev1
@freshdev1
i want to get rid of the old ones.
Daniel Willis
@danww
Check it now.
I remember having this issue before - you need to iterate over the formArray and removeAt()
freshdev1
@freshdev1
Hmmm it works on this simplified example but it won't on my local project.
Daniel Willis
@danww
Hmmm - can you spot what is different?
freshdev1
@freshdev1
Works now. I was using formArray.clear() to clear out old objects. which was causing some issue, I don't know.
Was also using it with removeAt
Final working code:
onDocumentUpdate(documentsArray: DocumentModel[]): void{
    if(documentsArray == undefined)
    {
      return; 
    }

    var docsControls = this.contractForm.controls["TenantContractDocuments"] as FormArray;

    while(docsControls.length !== 0)
    {
      docsControls.removeAt(0);
    }

    documentsArray.forEach((element: DocumentModel) => {
      let docGroup = this.formBuilder.formGroup(DocumentSubmission);
      let document = element as DocumentSubmission;

      docGroup.patchValue(document);
      docsControls.push(docGroup);
    });
  }
Daniel Willis
@danww
I don't think formArray.clear() is a thing, unless it's in the RxWeb library?
freshdev1
@freshdev1
What was not working:
onDocumentUpdate(documentsArray: DocumentModel[]): void{
    if(documentsArray == undefined)
    {
      return; 
    }

    var docsControls = this.contractForm.controls["TenantContractDocuments"] as FormArray;

    docsControls.clear();
   docsControls = new FormArray([]);

    while(docsControls.length !== 0)
    {
      docsControls.removeAt(0);
    }

    documentsArray.forEach((element: DocumentModel) => {
      let docGroup = this.formBuilder.formGroup(DocumentSubmission);
      let document = element as DocumentSubmission;

      docGroup.patchValue(document);
      docsControls.push(docGroup);
    });
  }
I read it on some of the answers and tried.
Its from the angular itself
Daniel Willis
@danww
Yeah, docsControl needs to remain a reference to the existing formArray
hmmm makes sense, I was reassigning it to the parent form even after initializing a new one. But that too was not working.
thanks for the help! :smile:
Daniel Willis
@danww
No worries.
Weird, .clear() is in the docs: https://angular.io/api/forms/FormArray#clear
But doesn't seem to exist. IDE/Stackblitz throws error.
freshdev1
@freshdev1
yeah. there is definitely some issues with it. on my local it exists and works, but when I use it it won't update the actual main FORMGROUP.
that was where I was having hard time
freshdev1
@freshdev1
this was how I was doing at another place:
    var contractedBeds = this.contractedBedsFormGroup.controls['AddContractedBeds'] as FormArray;
    contractedBeds.clear();

    //remove all the objects from form array:
    while (contractedBeds.length !== 0) {
      contractedBeds.removeAt(0)
    }

    $event.forEach(element => {
      contractedBeds = this.formBuilder.array([this.formBuilder.formGroup(TenantContractContractedBed)]);

      let contractedBedsGroup = this.formBuilder.formGroup(TenantContractContractedBed);
      contractedBedsGroup.patchValue(element);
      contractedBeds.push(contractedBedsGroup);  
    });

    this.contractedBedsFormGroup.controls["AddContractedBeds"] = contractedBeds; //I was doing this also with an understanding may be it is loosing the reference
Daniel Willis
@danww
I think it's best to stick with referencing the original formArray and modifying it, rather than replacing it. Especially if you have any exisiting subscriptions elsewhere that might be listening to it.
freshdev1
@freshdev1
Agree. I didn't do it in the start, but rather when clear and removeAt was not working, I added it. But now I have removed this line.
Daniel Willis
@danww
Cool cool.
Aishasadat123
@Aishasadat123
what is wrong i this swich case ?
<input type="number" class="form-control" formControlName="{{ child.formControlName }}" />
          <div [ngSwitch]="type">
            <input
              *ngSwitchCase="number"
              class="form-control"
              formControlName="{{ child.type.formControlName }}"
            />
            <ng-select
              *ngSwitchCase="select"
              [items]=""
              class="text-capitalize"
              [searchable]="true"
              formControlName="{{ child.type.formControlName }}"
            >
            </ng-select>
          </div>
Tiantang Sun
@stt106
should I create a component for each CRUD operation or use a single component for all?
DrewMoody
@DrewMoody

I haven't looked into this yet, but does anyone know if you can access context of an element through ViewChildren? Specifically trying to grab context for a mat-row in a mat-table

<tr mat-row *matRowDef="let row; columns: columns"></tr>

I am hoping for access to that row context

Dominic Watson
@intellix
I'm trying to debug performance issues by using Chrome Developer Tools performance recording and analysing the output.... but it's just polluted by Zone. The whole thing is basically: 100% used inside Zone. How am I meant to address performance issues if zone just wraps everything and consumes all knowledge about what's happening?
it makes everything unreadable and unusable I just can't read the output
SAGO
@SAGOlab
Hi there, someone have some news about csp (content security policy)? I need to pass a dynamic nonce to inline style and script, and I cannot use unsafe inline because of internal policy, there is a way to achieve this? Extending webpack or in another way? Thanks
Urban
@UrKr
Wish you could use rxjs operators on component inputs
Amin Bashanfar
@Amin-bash
Hello guys, I have an input that has a card number and I want to put space between every 4 numbers how can I do that
Urban
@UrKr
@mlc-mlapis Interesting, thanks for the links
Pankaj Sharma
@iimphoenix310_twitter
Hi im new to Angular development. Im from India. Can anyone please suggest a better way to use AMP with Angular?
mridul-netizen
@mridul-netizen
Can we use angular universal for SSR purposes if the backend is in Flask?
Also are there some advantages of using EventEmitters over Subject for cross component communication?