I am new to angular I want to add dynamic array index value in html page. I tried different solution I am not getting a solutions. I am not getting any error as well.
I have create a array in typescript as shown below
my typescript
months : string[] = ['January','February','March','April','May','June','July','August','September','October','November','December'];
the above array I want to pass dynamic index value in html page. I tried but I am not getting the value.
I tried like this {{ months[ result.startDate.split('/')[1] ] }} . If i type static index value it is working.
html page
<div class="row" style="width: 110%;" *ngFor="let result of allEvents">
<p class="start-date" >{{ result.startDate.split('/')[0] }} </p> <br><p >{{ months[ result.startDate.split('/')[1] ] }} </p>
</div>
result object I am getting
0:
_id: "5e8b033bd3d04a24db92288a"
name: "Casting call for kannada movie"
description: "Looking for:↵Female artist Age: 17-26↵Kids Age :4-12"
startTime: "6"
endTime: "21"
startDate: "04/04/2020"
endDate: "31/05/2020"
participant: []
userId: "5e536de00d691f6427bcaec1"
pageId: {profileImage: {…}, coverPage: {…}, isBlocked: false, softDelete: false, isVerified: true, …}
createdAt: "2020-04-06T10:23:55.874Z"
updatedAt: "2020-04-06T10:23:55.874Z"
please help me
thanks in advance
resultobjectresult.startDate.split('/')[1]and see the outputresult.startDate.split('/')[1]I am getting value as 04startDate: "04/04/2020", what do you want to display in template?