Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 20:02
    ibra4 starred angular/angular
  • 20:01
    zarend unlabeled #41020
  • 20:01
    zarend labeled #41020
  • 20:01
    zarend commented #41020
  • 20:01
    zarend commented #40987
  • 20:01
    zarend commented #40987
  • 19:58
    alxhub labeled #41021
  • 19:58
    alxhub labeled #41021
  • 19:58
    alxhub review_requested #41021
  • 19:58
    google-cla[bot] labeled #41021
  • 19:58
    alxhub opened #41021
  • 19:50
    aikidave review_requested #39938
  • 19:47
    aikidave review_requested #40732
  • 19:39
    aikidave commented #40897
  • 19:38
    aikidave review_requested #40897
  • 19:35
    aikidave review_requested #40924
  • 19:30
    aikidave review_requested #40942
  • 19:30
    aikidave commented #40942
  • 19:20
    aikidave review_requested #40992
  • 19:18
    pullapprove[bot] review_requested #40992
Shaik Irfan
@Irfan354
itll be helpful
Xava\du
@xavadu_twitter
@Irfan354 follow the Angular tutorial to start https://angular.io/tutorial
cuznerdexter
@cuznerdexter

Hi, I have an issue with ViewContainers.
I have a custom structural directive = eg “permissionAccess" it selects data from my NGRX store and looks for matching permissions.
If no permission it clears the ViewContainer,
If has permission if Rebuilds the ViewContainer using the injected TemplateRef
(This all works fine - I have tested with Dom elements, Components, Views)
But… it fails to rebuild the ViewContainer if any of the Dom contains
ngIf directives.
Anyone know why this would happen?? I have no idea!
It even fails with the "*ngIf=“true”"

Template Example Works:

<div *cwbPermission=“'ADMIN'">
        <p>test container</p>
        <div>
          <p>Nested container1</p>
          <div>
            <p>Nested container2</p>
          </div>
        </div>
      </div>

Template Example Fails:

<div *cwbPermission=“'ADMIN'">
        <p>test container</p>
        <div *ngIf=“true">
          <p>Nested container1</p>
          <div>
            <p>Nested container2</p>
          </div>
        </div>
      </div>
cuznerdexter
@cuznerdexter
So, I am not sure if this the best approach to this issue but looks like it is working for me. I added a changeDetectorRef.detectChanges() after creating the template in the view container and the UI now updates as I expect. Not seen any issues so far.
 /**
  * Creates the template content
  */
  showContent(): void {
    this.viewContainer.remove();
    this.viewContainer.createEmbeddedView(this.templateRef, this.context, 0);
    this.cdref.detectChanges();
  }
itsmenabil
@itsmenabil
hey guys, im new to this, can anyone please help me solve this code so i can join codewars
function multiply(a , b){
a * b
}
mogo-edenpark
@mogo-edenpark
function multiply(a , b){
   return a * b;


}
@itsmenabil
nunobotelhokk
@nunobotelhokk
I'm having some issues validating a form control. I'm setting this as a validator:
[
                Validators.required,
                Validators.minLength(9),
                Validators.maxLength(32)
        ]
But it only gives me the required error
If i remove the required, the control is always valid...
any idea on what i'm missing?
I have exactly the same validation on another place and it works fine.
mogo-edenpark
@mogo-edenpark
this.userForm = this.userFB.group({
            username: [
                "",
                Validators.compose([
                    Validators.required,
                    Validators.minLength(3),
                    Validators.maxLength(200),
                ]),
            ],
nunobotelhokk
@nunobotelhokk
I tried that, no luck.
mogo-edenpark
@mogo-edenpark
<mat-error
                                                    *ngIf="
                                                        isControlHasError(
                                                            'roles',
                                                            'required'
                                                        )
                                                    "
                                                >
                                                    <strong>{{

                                                        "AUTH.VALIDATION.REQUIRED_FIELD"
                                                            | translate
                                                    }}</strong>
                                                </mat-error>
    isControlHasError(controlName: string, validationType: string): boolean {
        const control = this.userForm.controls[controlName];

        if (!control) {
            return false;
        }
        const result =
            control.hasError(validationType) &&
            (control.dirty || control.touched);
        return result;
    }
This will solve
nunobotelhokk
@nunobotelhokk
But why do i need to do that? This isnt even a tricky validation to be done
mogo-edenpark
@mogo-edenpark
I think you need a setting or something to my knowledge
in the doc they are still doing manually like this
<div *ngIf="heroForm.errors?.identityRevealed && (heroForm.touched || heroForm.dirty)" class="cross-validation-error-message alert alert-danger">
    Name cannot match alter ego.
</div>
like this.. That's all I know
Daniel Willis
@danww
@nunobotelhokk Can you reproduce in a Stackblitz instance?
mogo-edenpark
@mogo-edenpark
required is showing error because input has a property for required but not the length
nunobotelhokk
@nunobotelhokk
@danww its actually hard to reproduce, since i have this control on different forms. In one form he does validate correctly, in the other he doesnt. I'm not sure if i need to provide anything on the related module
Actually, they belong to the same module..
Daniel Willis
@danww
@nunobotelhokk K. It's just difficult to see the context without a working code example.
@nunobotelhokk And sometimes just the process of reproducing an issue in a Stackblitz means the solution becomes clear.
nunobotelhokk
@nunobotelhokk
Yup, ill try there.
nunobotelhokk
@nunobotelhokk
Thats it
But i dont think i'm doing anything different :joy:
Yup, found it
it seems that i cannot give it the input type of number...
Fkin hell...
Daniel Willis
@danww
So you can't validate minLength and maxLength on input with type="number"?
nunobotelhokk
@nunobotelhokk
It's the only thing i've changed, so i assume thats the issue with it
For number types, we should use min and max, and never minLength or maxLength
Validators.min(10000000000), Validators.max(999999999999)]
Should do something like that instead
Daniel Willis
@danww
:thumbsup:
That's good to know
I'm pleased you figured it out! :)
nunobotelhokk
@nunobotelhokk
Ye, it was messing with my head
Thanks for the help
Daniel Willis
@danww
No problem. I know it often seems like a lot of work and a real pain in the a**, but making a Stackblitz of the problem is such a helpful thing to do.
nunobotelhokk
@nunobotelhokk
Indeed.
FazilSog
@FazilSog

hello everybody
I m beginer on Angular generally & 8 specifically

So I cloned a git project et than I launched an npm install tu get back all projet dependencies

and after that I installedangular with npm install -g @angular/cli@8.1.3

Finally I lauched the server with ng serve -o