ExpressionChangedAfterItHasBeenCheckedError: Expression Error On Datepicker Value retrieve



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I keep getting this error and I can't seem to find a way to fix this. I using this angular 4 datepicker in my project and in this error occurs when it detects change on the dateChanged event.



Here's my full error:




EditApplicationComponent.html:522 ERROR Error:
ExpressionChangedAfterItHasBeenCheckedError: Expression has changed
after it was checked. Previous value: '[object Object]'. Current
value: ''.




Here's my html.



<tr *ngFor="let rpr of DocumentMode">

<td style="width: 18%">

<my-date-picker name="from" [options]="DocDatePickerOptions" (dateChanged)="onDocDateChanged($event, rpr)" [ngModelOptions]="standalone: true" [placeholder]="placeholder"
[ngModel]="rpr.SD_VALID_FROM" ></my-date-picker>
</td>
<tr>


Here's how I binded and get value to the datepicker. in sample.ts



OnInit()

this.DocDateRetreive();




DocDateRetreive()
console.log("came here", this.DocumentMode);
for (var i = 0; i < this.DocumentMode.length; i++)
if (this.DocumentMode[i].SD_VALID_FROM == null)
// this.validFrom[i] = new Date();

else
console.log("from:", this.DocumentMode[i].SD_VALID_FROM);

var validFromTemp = [new Date(this.DocumentMode[i].SD_VALID_FROM)];

for (var j = 0; j < validFromTemp.length; j++)
console.log("valid from temp:", validFromTemp[j]);
this.validFrom[i] = date: year: validFromTemp[j].getFullYear(), month: validFromTemp[j].getMonth() + 1, day: validFromTemp[j].getDate() ;

console.log("valid", this.validFrom[i]);
this.DocumentMode[i].SD_VALID_FROM = this.validFrom[i];





onDocDateChanged(event: IMyDateModel, rpr)

var date = event.formatted;
rpr.SD_VALID_FROM = date;
console.log("changed", rpr.SD_VALID_FROM);




readThis(inputValue: any, rpr): void

myReader.onloadend = (e) =>
this.FileString = myReader.result;
// rpr.SD_VALID_FROM = this.validFrom.formatted;
for (var i = 0; i < this.DocumentMode.length; i++)
if (this.DocumentMode[i].DOC_ATTCHE_PATH == rpr.DOC_ATTCHE_PATH)

this.DocumentMode[i].SD_VALID_FROM = rpr.SD_VALID_FROM.formatted;
this.DocumentMode[i].SD_VALID_UNTIL = rpr.SD_VALID_UNTIL;
this.DocumentMode[i].IS_CHECK = true;



myReader.readAsDataURL(file);




The Datepicker works fine but when it first loads the DOM the error occurs. How do I resolve this issue. Help would be appreciated.










share|improve this question
























  • Have you seen this: stackoverflow.com/questions/43375532/… ?

    – Titian Cernicova-Dragomir
    Nov 15 '18 at 9:22






  • 1





    Possible duplicate of ExpressionChangedAfterItHasBeenCheckedError Explained

    – Bytech
    Nov 15 '18 at 9:49











  • Günter Zöchbauer from the link Titian posts above perfectly explains the problem and why it really should be addressed. At the time of writing, Günter's answer is second in popularity, behind the first by just one vote. No answer was marked as officially accepted.

    – Bytech
    Nov 15 '18 at 9:52


















0















I keep getting this error and I can't seem to find a way to fix this. I using this angular 4 datepicker in my project and in this error occurs when it detects change on the dateChanged event.



Here's my full error:




EditApplicationComponent.html:522 ERROR Error:
ExpressionChangedAfterItHasBeenCheckedError: Expression has changed
after it was checked. Previous value: '[object Object]'. Current
value: ''.




Here's my html.



<tr *ngFor="let rpr of DocumentMode">

<td style="width: 18%">

<my-date-picker name="from" [options]="DocDatePickerOptions" (dateChanged)="onDocDateChanged($event, rpr)" [ngModelOptions]="standalone: true" [placeholder]="placeholder"
[ngModel]="rpr.SD_VALID_FROM" ></my-date-picker>
</td>
<tr>


Here's how I binded and get value to the datepicker. in sample.ts



OnInit()

this.DocDateRetreive();




DocDateRetreive()
console.log("came here", this.DocumentMode);
for (var i = 0; i < this.DocumentMode.length; i++)
if (this.DocumentMode[i].SD_VALID_FROM == null)
// this.validFrom[i] = new Date();

else
console.log("from:", this.DocumentMode[i].SD_VALID_FROM);

var validFromTemp = [new Date(this.DocumentMode[i].SD_VALID_FROM)];

for (var j = 0; j < validFromTemp.length; j++)
console.log("valid from temp:", validFromTemp[j]);
this.validFrom[i] = date: year: validFromTemp[j].getFullYear(), month: validFromTemp[j].getMonth() + 1, day: validFromTemp[j].getDate() ;

console.log("valid", this.validFrom[i]);
this.DocumentMode[i].SD_VALID_FROM = this.validFrom[i];





onDocDateChanged(event: IMyDateModel, rpr)

var date = event.formatted;
rpr.SD_VALID_FROM = date;
console.log("changed", rpr.SD_VALID_FROM);




readThis(inputValue: any, rpr): void

myReader.onloadend = (e) =>
this.FileString = myReader.result;
// rpr.SD_VALID_FROM = this.validFrom.formatted;
for (var i = 0; i < this.DocumentMode.length; i++)
if (this.DocumentMode[i].DOC_ATTCHE_PATH == rpr.DOC_ATTCHE_PATH)

this.DocumentMode[i].SD_VALID_FROM = rpr.SD_VALID_FROM.formatted;
this.DocumentMode[i].SD_VALID_UNTIL = rpr.SD_VALID_UNTIL;
this.DocumentMode[i].IS_CHECK = true;



myReader.readAsDataURL(file);




The Datepicker works fine but when it first loads the DOM the error occurs. How do I resolve this issue. Help would be appreciated.










share|improve this question
























  • Have you seen this: stackoverflow.com/questions/43375532/… ?

    – Titian Cernicova-Dragomir
    Nov 15 '18 at 9:22






  • 1





    Possible duplicate of ExpressionChangedAfterItHasBeenCheckedError Explained

    – Bytech
    Nov 15 '18 at 9:49











  • Günter Zöchbauer from the link Titian posts above perfectly explains the problem and why it really should be addressed. At the time of writing, Günter's answer is second in popularity, behind the first by just one vote. No answer was marked as officially accepted.

    – Bytech
    Nov 15 '18 at 9:52














0












0








0








I keep getting this error and I can't seem to find a way to fix this. I using this angular 4 datepicker in my project and in this error occurs when it detects change on the dateChanged event.



Here's my full error:




EditApplicationComponent.html:522 ERROR Error:
ExpressionChangedAfterItHasBeenCheckedError: Expression has changed
after it was checked. Previous value: '[object Object]'. Current
value: ''.




Here's my html.



<tr *ngFor="let rpr of DocumentMode">

<td style="width: 18%">

<my-date-picker name="from" [options]="DocDatePickerOptions" (dateChanged)="onDocDateChanged($event, rpr)" [ngModelOptions]="standalone: true" [placeholder]="placeholder"
[ngModel]="rpr.SD_VALID_FROM" ></my-date-picker>
</td>
<tr>


Here's how I binded and get value to the datepicker. in sample.ts



OnInit()

this.DocDateRetreive();




DocDateRetreive()
console.log("came here", this.DocumentMode);
for (var i = 0; i < this.DocumentMode.length; i++)
if (this.DocumentMode[i].SD_VALID_FROM == null)
// this.validFrom[i] = new Date();

else
console.log("from:", this.DocumentMode[i].SD_VALID_FROM);

var validFromTemp = [new Date(this.DocumentMode[i].SD_VALID_FROM)];

for (var j = 0; j < validFromTemp.length; j++)
console.log("valid from temp:", validFromTemp[j]);
this.validFrom[i] = date: year: validFromTemp[j].getFullYear(), month: validFromTemp[j].getMonth() + 1, day: validFromTemp[j].getDate() ;

console.log("valid", this.validFrom[i]);
this.DocumentMode[i].SD_VALID_FROM = this.validFrom[i];





onDocDateChanged(event: IMyDateModel, rpr)

var date = event.formatted;
rpr.SD_VALID_FROM = date;
console.log("changed", rpr.SD_VALID_FROM);




readThis(inputValue: any, rpr): void

myReader.onloadend = (e) =>
this.FileString = myReader.result;
// rpr.SD_VALID_FROM = this.validFrom.formatted;
for (var i = 0; i < this.DocumentMode.length; i++)
if (this.DocumentMode[i].DOC_ATTCHE_PATH == rpr.DOC_ATTCHE_PATH)

this.DocumentMode[i].SD_VALID_FROM = rpr.SD_VALID_FROM.formatted;
this.DocumentMode[i].SD_VALID_UNTIL = rpr.SD_VALID_UNTIL;
this.DocumentMode[i].IS_CHECK = true;



myReader.readAsDataURL(file);




The Datepicker works fine but when it first loads the DOM the error occurs. How do I resolve this issue. Help would be appreciated.










share|improve this question
















I keep getting this error and I can't seem to find a way to fix this. I using this angular 4 datepicker in my project and in this error occurs when it detects change on the dateChanged event.



Here's my full error:




EditApplicationComponent.html:522 ERROR Error:
ExpressionChangedAfterItHasBeenCheckedError: Expression has changed
after it was checked. Previous value: '[object Object]'. Current
value: ''.




Here's my html.



<tr *ngFor="let rpr of DocumentMode">

<td style="width: 18%">

<my-date-picker name="from" [options]="DocDatePickerOptions" (dateChanged)="onDocDateChanged($event, rpr)" [ngModelOptions]="standalone: true" [placeholder]="placeholder"
[ngModel]="rpr.SD_VALID_FROM" ></my-date-picker>
</td>
<tr>


Here's how I binded and get value to the datepicker. in sample.ts



OnInit()

this.DocDateRetreive();




DocDateRetreive()
console.log("came here", this.DocumentMode);
for (var i = 0; i < this.DocumentMode.length; i++)
if (this.DocumentMode[i].SD_VALID_FROM == null)
// this.validFrom[i] = new Date();

else
console.log("from:", this.DocumentMode[i].SD_VALID_FROM);

var validFromTemp = [new Date(this.DocumentMode[i].SD_VALID_FROM)];

for (var j = 0; j < validFromTemp.length; j++)
console.log("valid from temp:", validFromTemp[j]);
this.validFrom[i] = date: year: validFromTemp[j].getFullYear(), month: validFromTemp[j].getMonth() + 1, day: validFromTemp[j].getDate() ;

console.log("valid", this.validFrom[i]);
this.DocumentMode[i].SD_VALID_FROM = this.validFrom[i];





onDocDateChanged(event: IMyDateModel, rpr)

var date = event.formatted;
rpr.SD_VALID_FROM = date;
console.log("changed", rpr.SD_VALID_FROM);




readThis(inputValue: any, rpr): void

myReader.onloadend = (e) =>
this.FileString = myReader.result;
// rpr.SD_VALID_FROM = this.validFrom.formatted;
for (var i = 0; i < this.DocumentMode.length; i++)
if (this.DocumentMode[i].DOC_ATTCHE_PATH == rpr.DOC_ATTCHE_PATH)

this.DocumentMode[i].SD_VALID_FROM = rpr.SD_VALID_FROM.formatted;
this.DocumentMode[i].SD_VALID_UNTIL = rpr.SD_VALID_UNTIL;
this.DocumentMode[i].IS_CHECK = true;



myReader.readAsDataURL(file);




The Datepicker works fine but when it first loads the DOM the error occurs. How do I resolve this issue. Help would be appreciated.







angular typescript datepicker






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 11:17







Ashane Alvis

















asked Nov 15 '18 at 9:18









Ashane AlvisAshane Alvis

40321227




40321227












  • Have you seen this: stackoverflow.com/questions/43375532/… ?

    – Titian Cernicova-Dragomir
    Nov 15 '18 at 9:22






  • 1





    Possible duplicate of ExpressionChangedAfterItHasBeenCheckedError Explained

    – Bytech
    Nov 15 '18 at 9:49











  • Günter Zöchbauer from the link Titian posts above perfectly explains the problem and why it really should be addressed. At the time of writing, Günter's answer is second in popularity, behind the first by just one vote. No answer was marked as officially accepted.

    – Bytech
    Nov 15 '18 at 9:52


















  • Have you seen this: stackoverflow.com/questions/43375532/… ?

    – Titian Cernicova-Dragomir
    Nov 15 '18 at 9:22






  • 1





    Possible duplicate of ExpressionChangedAfterItHasBeenCheckedError Explained

    – Bytech
    Nov 15 '18 at 9:49











  • Günter Zöchbauer from the link Titian posts above perfectly explains the problem and why it really should be addressed. At the time of writing, Günter's answer is second in popularity, behind the first by just one vote. No answer was marked as officially accepted.

    – Bytech
    Nov 15 '18 at 9:52

















Have you seen this: stackoverflow.com/questions/43375532/… ?

– Titian Cernicova-Dragomir
Nov 15 '18 at 9:22





Have you seen this: stackoverflow.com/questions/43375532/… ?

– Titian Cernicova-Dragomir
Nov 15 '18 at 9:22




1




1





Possible duplicate of ExpressionChangedAfterItHasBeenCheckedError Explained

– Bytech
Nov 15 '18 at 9:49





Possible duplicate of ExpressionChangedAfterItHasBeenCheckedError Explained

– Bytech
Nov 15 '18 at 9:49













Günter Zöchbauer from the link Titian posts above perfectly explains the problem and why it really should be addressed. At the time of writing, Günter's answer is second in popularity, behind the first by just one vote. No answer was marked as officially accepted.

– Bytech
Nov 15 '18 at 9:52






Günter Zöchbauer from the link Titian posts above perfectly explains the problem and why it really should be addressed. At the time of writing, Günter's answer is second in popularity, behind the first by just one vote. No answer was marked as officially accepted.

– Bytech
Nov 15 '18 at 9:52













1 Answer
1






active

oldest

votes


















0














Try doing this this.DocDateRetreive(); after view init.
there is an angular lifecycle hook called AfterViewInit. You need to implement the inteface in your component class.



export class YourComponent implements AfterViewInit
constructor()
/*Whatever*/


ngAfterViewInit(): void
this.DocDateRetreive();




This should solve your problem.



If the incoming data you use is making the problem, then you need to go for
AfterContentInit



export class YourComponent implements AfterContentInit 
constructor()
/*Whatever*/


ngAfterContentInit (): void
this.DocDateRetreive();







share|improve this answer

























  • Thank you. I'll check and see.

    – Ashane Alvis
    Nov 15 '18 at 9:29











  • Vote and Accept answer if this got to fix your issue.

    – Jins Peter
    Nov 15 '18 at 10:12











  • Hi When I put ngAfterContentInit () The date doesn't show in the datepicker. ngAfterViewInit() won't work

    – Ashane Alvis
    Nov 15 '18 at 10:13












  • Try ngAfterContentInit() and debug to find the issue?

    – Jins Peter
    Nov 15 '18 at 10:31











  • above error happens when I try ngAfterContentInit()

    – Ashane Alvis
    Nov 15 '18 at 10:40











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%2f53316032%2fexpressionchangedafterithasbeencheckederror-expression-error-on-datepicker-valu%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Try doing this this.DocDateRetreive(); after view init.
there is an angular lifecycle hook called AfterViewInit. You need to implement the inteface in your component class.



export class YourComponent implements AfterViewInit
constructor()
/*Whatever*/


ngAfterViewInit(): void
this.DocDateRetreive();




This should solve your problem.



If the incoming data you use is making the problem, then you need to go for
AfterContentInit



export class YourComponent implements AfterContentInit 
constructor()
/*Whatever*/


ngAfterContentInit (): void
this.DocDateRetreive();







share|improve this answer

























  • Thank you. I'll check and see.

    – Ashane Alvis
    Nov 15 '18 at 9:29











  • Vote and Accept answer if this got to fix your issue.

    – Jins Peter
    Nov 15 '18 at 10:12











  • Hi When I put ngAfterContentInit () The date doesn't show in the datepicker. ngAfterViewInit() won't work

    – Ashane Alvis
    Nov 15 '18 at 10:13












  • Try ngAfterContentInit() and debug to find the issue?

    – Jins Peter
    Nov 15 '18 at 10:31











  • above error happens when I try ngAfterContentInit()

    – Ashane Alvis
    Nov 15 '18 at 10:40















0














Try doing this this.DocDateRetreive(); after view init.
there is an angular lifecycle hook called AfterViewInit. You need to implement the inteface in your component class.



export class YourComponent implements AfterViewInit
constructor()
/*Whatever*/


ngAfterViewInit(): void
this.DocDateRetreive();




This should solve your problem.



If the incoming data you use is making the problem, then you need to go for
AfterContentInit



export class YourComponent implements AfterContentInit 
constructor()
/*Whatever*/


ngAfterContentInit (): void
this.DocDateRetreive();







share|improve this answer

























  • Thank you. I'll check and see.

    – Ashane Alvis
    Nov 15 '18 at 9:29











  • Vote and Accept answer if this got to fix your issue.

    – Jins Peter
    Nov 15 '18 at 10:12











  • Hi When I put ngAfterContentInit () The date doesn't show in the datepicker. ngAfterViewInit() won't work

    – Ashane Alvis
    Nov 15 '18 at 10:13












  • Try ngAfterContentInit() and debug to find the issue?

    – Jins Peter
    Nov 15 '18 at 10:31











  • above error happens when I try ngAfterContentInit()

    – Ashane Alvis
    Nov 15 '18 at 10:40













0












0








0







Try doing this this.DocDateRetreive(); after view init.
there is an angular lifecycle hook called AfterViewInit. You need to implement the inteface in your component class.



export class YourComponent implements AfterViewInit
constructor()
/*Whatever*/


ngAfterViewInit(): void
this.DocDateRetreive();




This should solve your problem.



If the incoming data you use is making the problem, then you need to go for
AfterContentInit



export class YourComponent implements AfterContentInit 
constructor()
/*Whatever*/


ngAfterContentInit (): void
this.DocDateRetreive();







share|improve this answer















Try doing this this.DocDateRetreive(); after view init.
there is an angular lifecycle hook called AfterViewInit. You need to implement the inteface in your component class.



export class YourComponent implements AfterViewInit
constructor()
/*Whatever*/


ngAfterViewInit(): void
this.DocDateRetreive();




This should solve your problem.



If the incoming data you use is making the problem, then you need to go for
AfterContentInit



export class YourComponent implements AfterContentInit 
constructor()
/*Whatever*/


ngAfterContentInit (): void
this.DocDateRetreive();








share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 15 '18 at 10:12

























answered Nov 15 '18 at 9:22









Jins PeterJins Peter

1,293621




1,293621












  • Thank you. I'll check and see.

    – Ashane Alvis
    Nov 15 '18 at 9:29











  • Vote and Accept answer if this got to fix your issue.

    – Jins Peter
    Nov 15 '18 at 10:12











  • Hi When I put ngAfterContentInit () The date doesn't show in the datepicker. ngAfterViewInit() won't work

    – Ashane Alvis
    Nov 15 '18 at 10:13












  • Try ngAfterContentInit() and debug to find the issue?

    – Jins Peter
    Nov 15 '18 at 10:31











  • above error happens when I try ngAfterContentInit()

    – Ashane Alvis
    Nov 15 '18 at 10:40

















  • Thank you. I'll check and see.

    – Ashane Alvis
    Nov 15 '18 at 9:29











  • Vote and Accept answer if this got to fix your issue.

    – Jins Peter
    Nov 15 '18 at 10:12











  • Hi When I put ngAfterContentInit () The date doesn't show in the datepicker. ngAfterViewInit() won't work

    – Ashane Alvis
    Nov 15 '18 at 10:13












  • Try ngAfterContentInit() and debug to find the issue?

    – Jins Peter
    Nov 15 '18 at 10:31











  • above error happens when I try ngAfterContentInit()

    – Ashane Alvis
    Nov 15 '18 at 10:40
















Thank you. I'll check and see.

– Ashane Alvis
Nov 15 '18 at 9:29





Thank you. I'll check and see.

– Ashane Alvis
Nov 15 '18 at 9:29













Vote and Accept answer if this got to fix your issue.

– Jins Peter
Nov 15 '18 at 10:12





Vote and Accept answer if this got to fix your issue.

– Jins Peter
Nov 15 '18 at 10:12













Hi When I put ngAfterContentInit () The date doesn't show in the datepicker. ngAfterViewInit() won't work

– Ashane Alvis
Nov 15 '18 at 10:13






Hi When I put ngAfterContentInit () The date doesn't show in the datepicker. ngAfterViewInit() won't work

– Ashane Alvis
Nov 15 '18 at 10:13














Try ngAfterContentInit() and debug to find the issue?

– Jins Peter
Nov 15 '18 at 10:31





Try ngAfterContentInit() and debug to find the issue?

– Jins Peter
Nov 15 '18 at 10:31













above error happens when I try ngAfterContentInit()

– Ashane Alvis
Nov 15 '18 at 10:40





above error happens when I try ngAfterContentInit()

– Ashane Alvis
Nov 15 '18 at 10:40



















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%2f53316032%2fexpressionchangedafterithasbeencheckederror-expression-error-on-datepicker-valu%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

How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

Syphilis

Darth Vader #20