How to check dirty or pristine in Angular 5 modal form?How to check empty/undefined/null string in JavaScript?How do I check if an element is hidden in jQuery?How do I check if an array includes an object in JavaScript?How to Check if element is visible after scrolling?How to check if a string “StartsWith” another string?How do you check if a variable is an array in JavaScript?How to check whether a checkbox is checked in jQuery?How to check whether a string contains a substring in JavaScript?How to check for “undefined” in JavaScript?How to check if an object is an array?

What was redacted in the Yellowhammer report? (Point 15)

Stucturing information on this trade show banner

What officially disallows US presidents from driving?

A medieval fantasy adventurer lights a torch in a 100% pure oxygen room. What happens?

What explanation do proponents of a Scotland-NI bridge give for it breaking Brexit impasse?

Were Roman public roads build by private companies?

How to publish superseding results without creating enemies

Why don't Wizards use wrist straps to protect against disarming charms?

How to stabilise the bicycle seatpost and saddle when it is all the way up?

A simple problem about Rule

Why did it become so much more expensive to start a university?

Is there any way to land a rover on the Moon without using any thrusters?

Why do sellers care about down payments?

Make 1998 using the least possible digits 8

Double it your way

Is plasma membrane permeable to sucrose

What was the ultimate objective of The Party in 1984?

Cannot find Database Mail feature in SQL Server Express 2012 SP1

Is a suit against a University Dorm for changing policies on a whim likely to succeed (USA)?

POSIX compatible way to get user name associated with a user ID

Thematic, genred concepts in Ancient Greek?

2000s space film where an alien species has almost wiped out the human race in a war

Are space camera sensors usually round, or square?

Can you add polynomial terms to multiple linear regression?



How to check dirty or pristine in Angular 5 modal form?


How to check empty/undefined/null string in JavaScript?How do I check if an element is hidden in jQuery?How do I check if an array includes an object in JavaScript?How to Check if element is visible after scrolling?How to check if a string “StartsWith” another string?How do you check if a variable is an array in JavaScript?How to check whether a checkbox is checked in jQuery?How to check whether a string contains a substring in JavaScript?How to check for “undefined” in JavaScript?How to check if an object is an array?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am working in a form in a modal. I want to submit form only if the there are any change made to the form field. My form looks like below:



HTML



<form [formGroup]="productForm" *ngIf="productForm"
(ngSubmit)="submitUpdatedRecord(productForm.value)">

<input
type="text"
class="form-control"
formControlName="product_code"
name="product_code_clip"
placeholder="Enter Product Code Clip"
[(ngModel)]="editProductData.product_code" />

<button type="submit" class="btn btn-block btn-update" [disabled]=!productForm.valid>
UPDATE
</button>
</form>


TS



submitUpdatedRecord(formData: NgForm) {
console.log(formData.dirty);
return false;


I did ng-pristine check in Angular JS but I am not sure how to implement it with Angular 5?



Can anybody please help?










share|improve this question
































    0















    I am working in a form in a modal. I want to submit form only if the there are any change made to the form field. My form looks like below:



    HTML



    <form [formGroup]="productForm" *ngIf="productForm"
    (ngSubmit)="submitUpdatedRecord(productForm.value)">

    <input
    type="text"
    class="form-control"
    formControlName="product_code"
    name="product_code_clip"
    placeholder="Enter Product Code Clip"
    [(ngModel)]="editProductData.product_code" />

    <button type="submit" class="btn btn-block btn-update" [disabled]=!productForm.valid>
    UPDATE
    </button>
    </form>


    TS



    submitUpdatedRecord(formData: NgForm) {
    console.log(formData.dirty);
    return false;


    I did ng-pristine check in Angular JS but I am not sure how to implement it with Angular 5?



    Can anybody please help?










    share|improve this question




























      0












      0








      0








      I am working in a form in a modal. I want to submit form only if the there are any change made to the form field. My form looks like below:



      HTML



      <form [formGroup]="productForm" *ngIf="productForm"
      (ngSubmit)="submitUpdatedRecord(productForm.value)">

      <input
      type="text"
      class="form-control"
      formControlName="product_code"
      name="product_code_clip"
      placeholder="Enter Product Code Clip"
      [(ngModel)]="editProductData.product_code" />

      <button type="submit" class="btn btn-block btn-update" [disabled]=!productForm.valid>
      UPDATE
      </button>
      </form>


      TS



      submitUpdatedRecord(formData: NgForm) {
      console.log(formData.dirty);
      return false;


      I did ng-pristine check in Angular JS but I am not sure how to implement it with Angular 5?



      Can anybody please help?










      share|improve this question
















      I am working in a form in a modal. I want to submit form only if the there are any change made to the form field. My form looks like below:



      HTML



      <form [formGroup]="productForm" *ngIf="productForm"
      (ngSubmit)="submitUpdatedRecord(productForm.value)">

      <input
      type="text"
      class="form-control"
      formControlName="product_code"
      name="product_code_clip"
      placeholder="Enter Product Code Clip"
      [(ngModel)]="editProductData.product_code" />

      <button type="submit" class="btn btn-block btn-update" [disabled]=!productForm.valid>
      UPDATE
      </button>
      </form>


      TS



      submitUpdatedRecord(formData: NgForm) {
      console.log(formData.dirty);
      return false;


      I did ng-pristine check in Angular JS but I am not sure how to implement it with Angular 5?



      Can anybody please help?







      javascript jquery angular angular6 angular5






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 13:25







      nas

















      asked Mar 28 at 10:20









      nasnas

      9061 gold badge10 silver badges34 bronze badges




      9061 gold badge10 silver badges34 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0
















          Seems like you have a mix of Reactive and Template driven forms. I am not sure why you need [(ngModel)]. pristine and dirty are also available in Angular 5+. But you need to access it from your form group.



          submitUpdatedRecord() 
          console.log(this.productForm.pristine);



          FormGroup extends AbstractControl. You can find more information about available properties here.






          share|improve this answer
























            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/4.0/"u003ecc by-sa 4.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%2f55395142%2fhow-to-check-dirty-or-pristine-in-angular-5-modal-form%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
















            Seems like you have a mix of Reactive and Template driven forms. I am not sure why you need [(ngModel)]. pristine and dirty are also available in Angular 5+. But you need to access it from your form group.



            submitUpdatedRecord() 
            console.log(this.productForm.pristine);



            FormGroup extends AbstractControl. You can find more information about available properties here.






            share|improve this answer





























              0
















              Seems like you have a mix of Reactive and Template driven forms. I am not sure why you need [(ngModel)]. pristine and dirty are also available in Angular 5+. But you need to access it from your form group.



              submitUpdatedRecord() 
              console.log(this.productForm.pristine);



              FormGroup extends AbstractControl. You can find more information about available properties here.






              share|improve this answer



























                0














                0










                0









                Seems like you have a mix of Reactive and Template driven forms. I am not sure why you need [(ngModel)]. pristine and dirty are also available in Angular 5+. But you need to access it from your form group.



                submitUpdatedRecord() 
                console.log(this.productForm.pristine);



                FormGroup extends AbstractControl. You can find more information about available properties here.






                share|improve this answer













                Seems like you have a mix of Reactive and Template driven forms. I am not sure why you need [(ngModel)]. pristine and dirty are also available in Angular 5+. But you need to access it from your form group.



                submitUpdatedRecord() 
                console.log(this.productForm.pristine);



                FormGroup extends AbstractControl. You can find more information about available properties here.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 28 at 13:39









                Borys KuparBorys Kupar

                1,0767 silver badges19 bronze badges




                1,0767 silver badges19 bronze badges





















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















                    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%2f55395142%2fhow-to-check-dirty-or-pristine-in-angular-5-modal-form%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

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript