Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 13:43
    ngbot[bot] milestoned #34831
  • 13:43
    alan-agius4 labeled #34831
  • 13:43
    maximelafarie opened #34831
  • 13:36
    marcrobards starred angular/angular
  • 13:33
  • 13:33
    tapin13 starred angular/angular
  • 13:26
    robertbaselios starred angular/angular
  • 13:25
    Kriska commented #34806
  • 13:19
    petebacondarwin synchronize #34722
  • 13:16
    devversion commented #34661
  • 13:11
    devversion unlabeled #34661
  • 13:11
    devversion labeled #34661
  • 13:08
    petebacondarwin synchronize #34722
  • 13:07
    petebacondarwin labeled #32431
  • 13:07
    petebacondarwin assigned #32431
  • 13:05
    romzaanton starred angular/angular
  • 13:04
    petebacondarwin commented #33395
  • 13:02
    Kriska review_requested #34806
  • 13:02
    Kriska synchronize #34806
  • 13:00
    googlebot labeled #34830
power-amin
@power-amin
guys in HTML how can I check if the array is empty
and the array is inside an observable object
BertrandMarechal
@BertrandMarechal
does this make sense ?
@power-amin (arrasAsObservable|async)?.length
Aliaksei Kuncevič
@kuncevic
yeah a bit tricky. lets take this example https://stackblitz.com/edit/angular-ebqdz5?file=app%2Ffade%2Ffade.component.ts
they implement a component app-fade that you have to use to wrap a html element you want to fadein/fadeout
seems to me too much boilerplate for such a simple thing
BertrandMarechal
@BertrandMarechal
@kuncevic yeah, this is a factorized version - if you need it for one element only, then you'll do it just once
Aliaksei Kuncevič
@kuncevic
yeah I probably will stick to it then, didn't expect you have to write so much code for such a simple thing
and there is no build-in directives that can do just that, right?
power-amin
@power-amin
@BertrandMarechal I didn't get it
image.png
@BertrandMarechal if you see you find that I have caseStudies$ observable
and that observable I have inside an array and I want to make a condition on that array if it's empty
so I made like this
switchMap((aCase: Case) => {
aCase.studies.length > 0 ? this.isInvestigation = true : this.isInvestigation = false;
did you get it :))
BertrandMarechal
@BertrandMarechal
yeah
so if you want a ngIf to ccheck that for example, just do as follow
*ngIf="(caseStudies|async)?.length" <= this checks if length is > 0 after the observed value is evaluated
this is using the angular built in async pipe https://angular.io/api/common/AsyncPipe
power-amin
@power-amin
@BertrandMarechal this way I'll check the caseStudies object right ?
but there is inside that object arrays and I want to check one of them if that array it's empry
like I did here inside switchMap
aCase.studies.length > 0 ? this.isInvestigation = true : this.isInvestigation = false;
it works but I see an error in the console
image.png
@BertrandMarechal yeah bro it works in this way
*ngIf="(caseStudies|async)?.length"
but I didn't understand what it does that code
Siddharath Shankar Bhardwaj
@sobhardwaj
i want to add class on click too how to add that..
    <div  *ngFor="let last = last; let touchPoint of touchPointList | sortBy: ['sequence']">
        <span class="step" (click)="touchPointDetails(touchPoint)" 
[ngClass]="[touchPoint.reach_time? 'reached' : 'uncovered']">
{{touchPoint?.sequence ? touchPoint?.sequence : 0}}</span>
        <hr *ngIf="!last">
     </div>
BertrandMarechal
@BertrandMarechal
@power-amin the async pipe is subscribing to the obserbable, and returning the value the observable sent back (as in your example, aCase)
Heinz Hölzer
@frabbit

Hello,
I'm currently looking for a way to cut the noise when passing templates to components
Consider the following code:

<parent>
  <ng-template #child1><div>Test</div></ng-template>
  <ng-template #child2><div>Test</div></ng-template>
</parent>

Is it possible to create a structural directive that can be used like this or similar?

<parent>
  <div *asTemplate="#child1">Test</div>
  <div *asTemplate="#child2">Test</div>
</parent>

So that

  <div *asTemplate="#child1">Test</div>

desugars to

<ng-template #child1><div>Test</div></ng-template>

Directly using

<div *asTemplate #child1>Test</div>

doesn't work because the ref is part of the div.

Thx a lot!

Siddharath Shankar Bhardwaj
@sobhardwaj
[ngClass]="[touchPoint.reach_time? 'reached' : 'uncovered', 'btnStyle': loading ]"
this showing error i want onclick loading true...cant work
Eric Martinez
@ericmartinezr
and the error is...?
:wave: :wave:
Heinz Hölzer
@frabbit
Another question, attribute selectors for ContentChild like @ContentChild('[child]') are not supported right? At least they don't work for me. Ref selectors like @ContentChild('child')are the only ones working for me.
Eric Martinez
@ericmartinezr
ref selectors or components/directives
You can query services too, I had no idea
That's for viewchild, don't know if it works for contentchild/ren
Heinz Hölzer
@frabbit
thx, yes for viewchild more advanced selectors do work, but it seems that this is not the case for contentchild/ren.
Claudio Teixeira
@claudiotx7_twitter
Hello there guys. Just boostrapped a new angular project using "@angular/core": "~9.0.0-rc.8" and I still see zone.js in the dependencies
any idea why?
OMAR HEGAZI
@OmarHegazi94
hi guys
i have a node project in the back-end with 2 collections in the mongodb students and departments .. in the student model i'm i have a refrence to the department of the student by the id
in the front-end i have angular .. now when i make a get request it brings the (id department ) of the student and i want to display the name not the id
any idea how to do that ?
Jorrit
@jorrit-wehelp
angular way is usually to write a department component, which gets the id as input and does it's own query through a service to retrieve the other fields and displays the name
OMAR HEGAZI
@OmarHegazi94
@jorrit-wehelp i did that, but what is required now in the students table is to display the department name not by the id
code.png
code2.png
OMAR HEGAZI
@OmarHegazi94
Demo1.png
Jorrit
@jorrit-wehelp
well, I would prefer simpeler components doing only one thing (so be a <td><my-department department-id="{{ item.Department}}"></my-department>. But seems you are already retrieving all departments in this component, so i'd put those into a Map keyed on id, so you could then just do {{ departmentMap[item.Department].name }} in the template
OMAR HEGAZI
@OmarHegazi94
should it have any typescript to define what is the departmentMap ? @jorrit-wehelp