Angular 4 Typescript - Construct Array of Dates of subsequent 7 Days












1















I want construct an array of 7 dates. those dates will be 7 subsequent days from a SelectedDate. I have written following code in Component.ts



public selectedWeekDates: Date ;

public selectedWeek: Date = new Date();

SetSelectedWeekDates(): void {
var dte = new Date();
dte = this.selectedWeek;
for (let i: number = 1; i < 8; i++) {
this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);
}

}


my html is as follows



.
.
.
<ng-container *ngFor="let dates of selectedWeekDates">
<div style="padding: 10px;">
{{ dates| date:"dd" }}
</div>
</ng-container>
.
.
.


I am getting below error in console




TypeError: Unable to get property '0' of undefined or null reference
at xxxComponent.prototype.SetSelectedWeekDates (eval code:179:143)




May I know what is wrong in my code?










share|improve this question























  • I tried declaring it as public selectedWeekDates: Array<Date> = ;

    – captainsac
    Nov 20 '18 at 6:52











  • try to check it for (let i: number = 1; i < 8; i++) { if(this.selectedWeekDates[i - 1]){ this.selectedWeekDates[i - 1].setDate(dte.getDate() + i); } }

    – Fateme Fazli
    Nov 20 '18 at 6:55











  • I guess you are accessing null element in your array this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);, you should try this.selectedWeekDates.push()

    – Sarthak Aggarwal
    Nov 20 '18 at 6:57











  • @SarthakAggarwal No luck

    – captainsac
    Nov 20 '18 at 7:15
















1















I want construct an array of 7 dates. those dates will be 7 subsequent days from a SelectedDate. I have written following code in Component.ts



public selectedWeekDates: Date ;

public selectedWeek: Date = new Date();

SetSelectedWeekDates(): void {
var dte = new Date();
dte = this.selectedWeek;
for (let i: number = 1; i < 8; i++) {
this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);
}

}


my html is as follows



.
.
.
<ng-container *ngFor="let dates of selectedWeekDates">
<div style="padding: 10px;">
{{ dates| date:"dd" }}
</div>
</ng-container>
.
.
.


I am getting below error in console




TypeError: Unable to get property '0' of undefined or null reference
at xxxComponent.prototype.SetSelectedWeekDates (eval code:179:143)




May I know what is wrong in my code?










share|improve this question























  • I tried declaring it as public selectedWeekDates: Array<Date> = ;

    – captainsac
    Nov 20 '18 at 6:52











  • try to check it for (let i: number = 1; i < 8; i++) { if(this.selectedWeekDates[i - 1]){ this.selectedWeekDates[i - 1].setDate(dte.getDate() + i); } }

    – Fateme Fazli
    Nov 20 '18 at 6:55











  • I guess you are accessing null element in your array this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);, you should try this.selectedWeekDates.push()

    – Sarthak Aggarwal
    Nov 20 '18 at 6:57











  • @SarthakAggarwal No luck

    – captainsac
    Nov 20 '18 at 7:15














1












1








1








I want construct an array of 7 dates. those dates will be 7 subsequent days from a SelectedDate. I have written following code in Component.ts



public selectedWeekDates: Date ;

public selectedWeek: Date = new Date();

SetSelectedWeekDates(): void {
var dte = new Date();
dte = this.selectedWeek;
for (let i: number = 1; i < 8; i++) {
this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);
}

}


my html is as follows



.
.
.
<ng-container *ngFor="let dates of selectedWeekDates">
<div style="padding: 10px;">
{{ dates| date:"dd" }}
</div>
</ng-container>
.
.
.


I am getting below error in console




TypeError: Unable to get property '0' of undefined or null reference
at xxxComponent.prototype.SetSelectedWeekDates (eval code:179:143)




May I know what is wrong in my code?










share|improve this question














I want construct an array of 7 dates. those dates will be 7 subsequent days from a SelectedDate. I have written following code in Component.ts



public selectedWeekDates: Date ;

public selectedWeek: Date = new Date();

SetSelectedWeekDates(): void {
var dte = new Date();
dte = this.selectedWeek;
for (let i: number = 1; i < 8; i++) {
this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);
}

}


my html is as follows



.
.
.
<ng-container *ngFor="let dates of selectedWeekDates">
<div style="padding: 10px;">
{{ dates| date:"dd" }}
</div>
</ng-container>
.
.
.


I am getting below error in console




TypeError: Unable to get property '0' of undefined or null reference
at xxxComponent.prototype.SetSelectedWeekDates (eval code:179:143)




May I know what is wrong in my code?







angular typescript






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 6:49









captainsaccaptainsac

2,19121636




2,19121636













  • I tried declaring it as public selectedWeekDates: Array<Date> = ;

    – captainsac
    Nov 20 '18 at 6:52











  • try to check it for (let i: number = 1; i < 8; i++) { if(this.selectedWeekDates[i - 1]){ this.selectedWeekDates[i - 1].setDate(dte.getDate() + i); } }

    – Fateme Fazli
    Nov 20 '18 at 6:55











  • I guess you are accessing null element in your array this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);, you should try this.selectedWeekDates.push()

    – Sarthak Aggarwal
    Nov 20 '18 at 6:57











  • @SarthakAggarwal No luck

    – captainsac
    Nov 20 '18 at 7:15



















  • I tried declaring it as public selectedWeekDates: Array<Date> = ;

    – captainsac
    Nov 20 '18 at 6:52











  • try to check it for (let i: number = 1; i < 8; i++) { if(this.selectedWeekDates[i - 1]){ this.selectedWeekDates[i - 1].setDate(dte.getDate() + i); } }

    – Fateme Fazli
    Nov 20 '18 at 6:55











  • I guess you are accessing null element in your array this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);, you should try this.selectedWeekDates.push()

    – Sarthak Aggarwal
    Nov 20 '18 at 6:57











  • @SarthakAggarwal No luck

    – captainsac
    Nov 20 '18 at 7:15

















I tried declaring it as public selectedWeekDates: Array<Date> = ;

– captainsac
Nov 20 '18 at 6:52





I tried declaring it as public selectedWeekDates: Array<Date> = ;

– captainsac
Nov 20 '18 at 6:52













try to check it for (let i: number = 1; i < 8; i++) { if(this.selectedWeekDates[i - 1]){ this.selectedWeekDates[i - 1].setDate(dte.getDate() + i); } }

– Fateme Fazli
Nov 20 '18 at 6:55





try to check it for (let i: number = 1; i < 8; i++) { if(this.selectedWeekDates[i - 1]){ this.selectedWeekDates[i - 1].setDate(dte.getDate() + i); } }

– Fateme Fazli
Nov 20 '18 at 6:55













I guess you are accessing null element in your array this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);, you should try this.selectedWeekDates.push()

– Sarthak Aggarwal
Nov 20 '18 at 6:57





I guess you are accessing null element in your array this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);, you should try this.selectedWeekDates.push()

– Sarthak Aggarwal
Nov 20 '18 at 6:57













@SarthakAggarwal No luck

– captainsac
Nov 20 '18 at 7:15





@SarthakAggarwal No luck

– captainsac
Nov 20 '18 at 7:15












2 Answers
2






active

oldest

votes


















2














In your function, you are using setDate function on elements of this.selectedWeekDates while they are undefined. You should use this.selectedWeek or dte to get and set your dates as below:



SetSelectedWeekDates(): void {
let dte: Date = new Date(this.selectedWeek);
for (let i = 1; i < 8; i++) {
this.selectedWeekDates[i-1]=new Date(dte.setDate(dte.getDate() + 1));
}

}


Also instead of adding i after getDate(), add 1 as done above as setDate() function is incrementing dte by a day in every iteration which means dte is updated after every iteration.






share|improve this answer


























  • I displayed dte in Console Log. While using new Date() the log is Tue Nov 20 2018 14:21:29 GMT+0530 (India Standard Time) when this.selectedWeek is assigned dynamically from a database value then it is 2018-09-30T00:00:00. Does this have to do something with this issue?

    – captainsac
    Nov 20 '18 at 8:55













  • It is because it is showing the default format returned by new Date(). You can convert it to any other format you want. AssetDate() function updates the date it is called with but returns number in miliseconds so i converted it using new Date() in the loop for storing dates in this.selectedWeekDates

    – Nabil Shahid
    Nov 20 '18 at 9:05













  • If dte is showing today's date than it means that this.selectedWeek has todays date instead of 2018-09-30T00:00:00 because of this line ` dte = this.selectedWeek;`.

    – Nabil Shahid
    Nov 20 '18 at 9:14











  • @captainsac Good. Edited as you suggested.

    – Nabil Shahid
    Nov 20 '18 at 9:19











  • Accepting this answer after multiple trial and edits

    – captainsac
    Nov 20 '18 at 9:21



















0














Your selectedWeekDates is empty. Hence the error. Give this a try to fix it:



public selectedWeekDates: Date = new Array(7).fill(new Date());

public selectedWeek: Date = new Date();

SetSelectedWeekDates(): void {
var dte = new Date();
dte = this.selectedWeek;
for (let i: number = 1; i < 8; i++) {
this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);
}

}


This should fix the current error that you're getting. I'm not really sure what it is that you're trying to achieve here. So you might need to fix your logic a bit. All I'm able to see on the screen is 27, 7 times.



Here's a Sample StackBlitz for your ref.






share|improve this answer
























  • Sorry but it is giving error ERROR TypeError: Object doesn't support property or method 'getDate'

    – captainsac
    Nov 20 '18 at 7:28











  • Really? Not sure why, but I'm not able to see any such errors on the console. I just used the exact same logic as yours in the SetSelectedWeekDates method.

    – SiddAjmera
    Nov 20 '18 at 7:32











  • I displayed dte in Console Log. While using new Date() the log is Tue Nov 20 2018 14:21:29 GMT+0530 (India Standard Time) when this.selectedWeek is assigned dynamically from a database value then it is 2018-09-30T00:00:00. Does this have to do something with this issue?

    – captainsac
    Nov 20 '18 at 8:59











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387646%2fangular-4-typescript-construct-array-of-dates-of-subsequent-7-days%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














In your function, you are using setDate function on elements of this.selectedWeekDates while they are undefined. You should use this.selectedWeek or dte to get and set your dates as below:



SetSelectedWeekDates(): void {
let dte: Date = new Date(this.selectedWeek);
for (let i = 1; i < 8; i++) {
this.selectedWeekDates[i-1]=new Date(dte.setDate(dte.getDate() + 1));
}

}


Also instead of adding i after getDate(), add 1 as done above as setDate() function is incrementing dte by a day in every iteration which means dte is updated after every iteration.






share|improve this answer


























  • I displayed dte in Console Log. While using new Date() the log is Tue Nov 20 2018 14:21:29 GMT+0530 (India Standard Time) when this.selectedWeek is assigned dynamically from a database value then it is 2018-09-30T00:00:00. Does this have to do something with this issue?

    – captainsac
    Nov 20 '18 at 8:55













  • It is because it is showing the default format returned by new Date(). You can convert it to any other format you want. AssetDate() function updates the date it is called with but returns number in miliseconds so i converted it using new Date() in the loop for storing dates in this.selectedWeekDates

    – Nabil Shahid
    Nov 20 '18 at 9:05













  • If dte is showing today's date than it means that this.selectedWeek has todays date instead of 2018-09-30T00:00:00 because of this line ` dte = this.selectedWeek;`.

    – Nabil Shahid
    Nov 20 '18 at 9:14











  • @captainsac Good. Edited as you suggested.

    – Nabil Shahid
    Nov 20 '18 at 9:19











  • Accepting this answer after multiple trial and edits

    – captainsac
    Nov 20 '18 at 9:21
















2














In your function, you are using setDate function on elements of this.selectedWeekDates while they are undefined. You should use this.selectedWeek or dte to get and set your dates as below:



SetSelectedWeekDates(): void {
let dte: Date = new Date(this.selectedWeek);
for (let i = 1; i < 8; i++) {
this.selectedWeekDates[i-1]=new Date(dte.setDate(dte.getDate() + 1));
}

}


Also instead of adding i after getDate(), add 1 as done above as setDate() function is incrementing dte by a day in every iteration which means dte is updated after every iteration.






share|improve this answer


























  • I displayed dte in Console Log. While using new Date() the log is Tue Nov 20 2018 14:21:29 GMT+0530 (India Standard Time) when this.selectedWeek is assigned dynamically from a database value then it is 2018-09-30T00:00:00. Does this have to do something with this issue?

    – captainsac
    Nov 20 '18 at 8:55













  • It is because it is showing the default format returned by new Date(). You can convert it to any other format you want. AssetDate() function updates the date it is called with but returns number in miliseconds so i converted it using new Date() in the loop for storing dates in this.selectedWeekDates

    – Nabil Shahid
    Nov 20 '18 at 9:05













  • If dte is showing today's date than it means that this.selectedWeek has todays date instead of 2018-09-30T00:00:00 because of this line ` dte = this.selectedWeek;`.

    – Nabil Shahid
    Nov 20 '18 at 9:14











  • @captainsac Good. Edited as you suggested.

    – Nabil Shahid
    Nov 20 '18 at 9:19











  • Accepting this answer after multiple trial and edits

    – captainsac
    Nov 20 '18 at 9:21














2












2








2







In your function, you are using setDate function on elements of this.selectedWeekDates while they are undefined. You should use this.selectedWeek or dte to get and set your dates as below:



SetSelectedWeekDates(): void {
let dte: Date = new Date(this.selectedWeek);
for (let i = 1; i < 8; i++) {
this.selectedWeekDates[i-1]=new Date(dte.setDate(dte.getDate() + 1));
}

}


Also instead of adding i after getDate(), add 1 as done above as setDate() function is incrementing dte by a day in every iteration which means dte is updated after every iteration.






share|improve this answer















In your function, you are using setDate function on elements of this.selectedWeekDates while they are undefined. You should use this.selectedWeek or dte to get and set your dates as below:



SetSelectedWeekDates(): void {
let dte: Date = new Date(this.selectedWeek);
for (let i = 1; i < 8; i++) {
this.selectedWeekDates[i-1]=new Date(dte.setDate(dte.getDate() + 1));
}

}


Also instead of adding i after getDate(), add 1 as done above as setDate() function is incrementing dte by a day in every iteration which means dte is updated after every iteration.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 '18 at 9:20

























answered Nov 20 '18 at 8:03









Nabil ShahidNabil Shahid

67826




67826













  • I displayed dte in Console Log. While using new Date() the log is Tue Nov 20 2018 14:21:29 GMT+0530 (India Standard Time) when this.selectedWeek is assigned dynamically from a database value then it is 2018-09-30T00:00:00. Does this have to do something with this issue?

    – captainsac
    Nov 20 '18 at 8:55













  • It is because it is showing the default format returned by new Date(). You can convert it to any other format you want. AssetDate() function updates the date it is called with but returns number in miliseconds so i converted it using new Date() in the loop for storing dates in this.selectedWeekDates

    – Nabil Shahid
    Nov 20 '18 at 9:05













  • If dte is showing today's date than it means that this.selectedWeek has todays date instead of 2018-09-30T00:00:00 because of this line ` dte = this.selectedWeek;`.

    – Nabil Shahid
    Nov 20 '18 at 9:14











  • @captainsac Good. Edited as you suggested.

    – Nabil Shahid
    Nov 20 '18 at 9:19











  • Accepting this answer after multiple trial and edits

    – captainsac
    Nov 20 '18 at 9:21



















  • I displayed dte in Console Log. While using new Date() the log is Tue Nov 20 2018 14:21:29 GMT+0530 (India Standard Time) when this.selectedWeek is assigned dynamically from a database value then it is 2018-09-30T00:00:00. Does this have to do something with this issue?

    – captainsac
    Nov 20 '18 at 8:55













  • It is because it is showing the default format returned by new Date(). You can convert it to any other format you want. AssetDate() function updates the date it is called with but returns number in miliseconds so i converted it using new Date() in the loop for storing dates in this.selectedWeekDates

    – Nabil Shahid
    Nov 20 '18 at 9:05













  • If dte is showing today's date than it means that this.selectedWeek has todays date instead of 2018-09-30T00:00:00 because of this line ` dte = this.selectedWeek;`.

    – Nabil Shahid
    Nov 20 '18 at 9:14











  • @captainsac Good. Edited as you suggested.

    – Nabil Shahid
    Nov 20 '18 at 9:19











  • Accepting this answer after multiple trial and edits

    – captainsac
    Nov 20 '18 at 9:21

















I displayed dte in Console Log. While using new Date() the log is Tue Nov 20 2018 14:21:29 GMT+0530 (India Standard Time) when this.selectedWeek is assigned dynamically from a database value then it is 2018-09-30T00:00:00. Does this have to do something with this issue?

– captainsac
Nov 20 '18 at 8:55







I displayed dte in Console Log. While using new Date() the log is Tue Nov 20 2018 14:21:29 GMT+0530 (India Standard Time) when this.selectedWeek is assigned dynamically from a database value then it is 2018-09-30T00:00:00. Does this have to do something with this issue?

– captainsac
Nov 20 '18 at 8:55















It is because it is showing the default format returned by new Date(). You can convert it to any other format you want. AssetDate() function updates the date it is called with but returns number in miliseconds so i converted it using new Date() in the loop for storing dates in this.selectedWeekDates

– Nabil Shahid
Nov 20 '18 at 9:05







It is because it is showing the default format returned by new Date(). You can convert it to any other format you want. AssetDate() function updates the date it is called with but returns number in miliseconds so i converted it using new Date() in the loop for storing dates in this.selectedWeekDates

– Nabil Shahid
Nov 20 '18 at 9:05















If dte is showing today's date than it means that this.selectedWeek has todays date instead of 2018-09-30T00:00:00 because of this line ` dte = this.selectedWeek;`.

– Nabil Shahid
Nov 20 '18 at 9:14





If dte is showing today's date than it means that this.selectedWeek has todays date instead of 2018-09-30T00:00:00 because of this line ` dte = this.selectedWeek;`.

– Nabil Shahid
Nov 20 '18 at 9:14













@captainsac Good. Edited as you suggested.

– Nabil Shahid
Nov 20 '18 at 9:19





@captainsac Good. Edited as you suggested.

– Nabil Shahid
Nov 20 '18 at 9:19













Accepting this answer after multiple trial and edits

– captainsac
Nov 20 '18 at 9:21





Accepting this answer after multiple trial and edits

– captainsac
Nov 20 '18 at 9:21













0














Your selectedWeekDates is empty. Hence the error. Give this a try to fix it:



public selectedWeekDates: Date = new Array(7).fill(new Date());

public selectedWeek: Date = new Date();

SetSelectedWeekDates(): void {
var dte = new Date();
dte = this.selectedWeek;
for (let i: number = 1; i < 8; i++) {
this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);
}

}


This should fix the current error that you're getting. I'm not really sure what it is that you're trying to achieve here. So you might need to fix your logic a bit. All I'm able to see on the screen is 27, 7 times.



Here's a Sample StackBlitz for your ref.






share|improve this answer
























  • Sorry but it is giving error ERROR TypeError: Object doesn't support property or method 'getDate'

    – captainsac
    Nov 20 '18 at 7:28











  • Really? Not sure why, but I'm not able to see any such errors on the console. I just used the exact same logic as yours in the SetSelectedWeekDates method.

    – SiddAjmera
    Nov 20 '18 at 7:32











  • I displayed dte in Console Log. While using new Date() the log is Tue Nov 20 2018 14:21:29 GMT+0530 (India Standard Time) when this.selectedWeek is assigned dynamically from a database value then it is 2018-09-30T00:00:00. Does this have to do something with this issue?

    – captainsac
    Nov 20 '18 at 8:59
















0














Your selectedWeekDates is empty. Hence the error. Give this a try to fix it:



public selectedWeekDates: Date = new Array(7).fill(new Date());

public selectedWeek: Date = new Date();

SetSelectedWeekDates(): void {
var dte = new Date();
dte = this.selectedWeek;
for (let i: number = 1; i < 8; i++) {
this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);
}

}


This should fix the current error that you're getting. I'm not really sure what it is that you're trying to achieve here. So you might need to fix your logic a bit. All I'm able to see on the screen is 27, 7 times.



Here's a Sample StackBlitz for your ref.






share|improve this answer
























  • Sorry but it is giving error ERROR TypeError: Object doesn't support property or method 'getDate'

    – captainsac
    Nov 20 '18 at 7:28











  • Really? Not sure why, but I'm not able to see any such errors on the console. I just used the exact same logic as yours in the SetSelectedWeekDates method.

    – SiddAjmera
    Nov 20 '18 at 7:32











  • I displayed dte in Console Log. While using new Date() the log is Tue Nov 20 2018 14:21:29 GMT+0530 (India Standard Time) when this.selectedWeek is assigned dynamically from a database value then it is 2018-09-30T00:00:00. Does this have to do something with this issue?

    – captainsac
    Nov 20 '18 at 8:59














0












0








0







Your selectedWeekDates is empty. Hence the error. Give this a try to fix it:



public selectedWeekDates: Date = new Array(7).fill(new Date());

public selectedWeek: Date = new Date();

SetSelectedWeekDates(): void {
var dte = new Date();
dte = this.selectedWeek;
for (let i: number = 1; i < 8; i++) {
this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);
}

}


This should fix the current error that you're getting. I'm not really sure what it is that you're trying to achieve here. So you might need to fix your logic a bit. All I'm able to see on the screen is 27, 7 times.



Here's a Sample StackBlitz for your ref.






share|improve this answer













Your selectedWeekDates is empty. Hence the error. Give this a try to fix it:



public selectedWeekDates: Date = new Array(7).fill(new Date());

public selectedWeek: Date = new Date();

SetSelectedWeekDates(): void {
var dte = new Date();
dte = this.selectedWeek;
for (let i: number = 1; i < 8; i++) {
this.selectedWeekDates[i - 1].setDate(dte.getDate() + i);
}

}


This should fix the current error that you're getting. I'm not really sure what it is that you're trying to achieve here. So you might need to fix your logic a bit. All I'm able to see on the screen is 27, 7 times.



Here's a Sample StackBlitz for your ref.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 '18 at 7:16









SiddAjmeraSiddAjmera

15.5k31238




15.5k31238













  • Sorry but it is giving error ERROR TypeError: Object doesn't support property or method 'getDate'

    – captainsac
    Nov 20 '18 at 7:28











  • Really? Not sure why, but I'm not able to see any such errors on the console. I just used the exact same logic as yours in the SetSelectedWeekDates method.

    – SiddAjmera
    Nov 20 '18 at 7:32











  • I displayed dte in Console Log. While using new Date() the log is Tue Nov 20 2018 14:21:29 GMT+0530 (India Standard Time) when this.selectedWeek is assigned dynamically from a database value then it is 2018-09-30T00:00:00. Does this have to do something with this issue?

    – captainsac
    Nov 20 '18 at 8:59



















  • Sorry but it is giving error ERROR TypeError: Object doesn't support property or method 'getDate'

    – captainsac
    Nov 20 '18 at 7:28











  • Really? Not sure why, but I'm not able to see any such errors on the console. I just used the exact same logic as yours in the SetSelectedWeekDates method.

    – SiddAjmera
    Nov 20 '18 at 7:32











  • I displayed dte in Console Log. While using new Date() the log is Tue Nov 20 2018 14:21:29 GMT+0530 (India Standard Time) when this.selectedWeek is assigned dynamically from a database value then it is 2018-09-30T00:00:00. Does this have to do something with this issue?

    – captainsac
    Nov 20 '18 at 8:59

















Sorry but it is giving error ERROR TypeError: Object doesn't support property or method 'getDate'

– captainsac
Nov 20 '18 at 7:28





Sorry but it is giving error ERROR TypeError: Object doesn't support property or method 'getDate'

– captainsac
Nov 20 '18 at 7:28













Really? Not sure why, but I'm not able to see any such errors on the console. I just used the exact same logic as yours in the SetSelectedWeekDates method.

– SiddAjmera
Nov 20 '18 at 7:32





Really? Not sure why, but I'm not able to see any such errors on the console. I just used the exact same logic as yours in the SetSelectedWeekDates method.

– SiddAjmera
Nov 20 '18 at 7:32













I displayed dte in Console Log. While using new Date() the log is Tue Nov 20 2018 14:21:29 GMT+0530 (India Standard Time) when this.selectedWeek is assigned dynamically from a database value then it is 2018-09-30T00:00:00. Does this have to do something with this issue?

– captainsac
Nov 20 '18 at 8:59





I displayed dte in Console Log. While using new Date() the log is Tue Nov 20 2018 14:21:29 GMT+0530 (India Standard Time) when this.selectedWeek is assigned dynamically from a database value then it is 2018-09-30T00:00:00. Does this have to do something with this issue?

– captainsac
Nov 20 '18 at 8:59


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387646%2fangular-4-typescript-construct-array-of-dates-of-subsequent-7-days%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?