How to use the value of the forms components which are unchanged using ngModel?How do you disable browser Autocomplete on web form field / input tag?Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?How can I know which radio button is selected via jQuery?How to submit form data use jquery form in asp.net?How to prevent buttons from submitting formsHow can I set the default value for an HTML <select> element?Not all attributes binding to ng-modelCannot display HTML stringHow to identify a form field type in phpchange html form value, load page & click button

Can you pop microwave popcorn on a stove?

How to plot two curves with the same area under?

How would two worlds first establish an exchange rate between their currencies

How to improvise or make pot grip / pot handle

Are professors obligated to accept supervisory role? If not, how does it work?

How to finish my PhD?

Electric shock from pedals and guitar. Jacks too long?

What exactly is Apple Cider

How should Thaumaturgy's "three times as loud as normal" be interpreted?

Why is Sojdlg123aljg a common password?

How to convert P2O5 concentration to H3PO4 concentration?

Why can't some airports handle heavy aircraft while others do it easily (same runway length)?

Problem with listing a directory to grep

What happens when a file that is 100% paged in to the page cache gets modified by another process

What is the purpose of the rotating plate in front of the lock?

Why do the Brexit opposition parties not want a new election?

How to run NPCs with complicated mechanics?

Is a MySQL database a viable alternative to LDAP?

What's the biggest difference between these two photos?

Why does low tire pressure decrease fuel economy?

Why is it that I have to play this note on the piano as A sharp?

Capacitors with same voltage, same capacitance, same temp, different diameter?

Friend is very nitpicky about side comments I don't intend to be taken too seriously

How is the phase of 120V AC established in a North American home?



How to use the value of the forms components which are unchanged using ngModel?


How do you disable browser Autocomplete on web form field / input tag?Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?How can I know which radio button is selected via jQuery?How to submit form data use jquery form in asp.net?How to prevent buttons from submitting formsHow can I set the default value for an HTML <select> element?Not all attributes binding to ng-modelCannot display HTML stringHow to identify a form field type in phpchange html form value, load page & click button






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








0















I am making a form and want to using the previous values as "value" in the form and by using ngModel dynamically changing some properties but the the field which is not changed by the user, the property is not retaining the previous value even.



<form #edit="ngForm" (submit)="editProfile(edit.value)">
<fieldset>
<div class="form-group">
<label for="username">Username : </label>&nbsp;&nbsp;@user.username
</div>
<div class="form-group">
<label for="name">Name :</label>&nbsp;&nbsp;@user.name
<input type="text" name="edit_name" class="form-control" id="name" value=user.name ngModel>
</div>
<div class="form-group">
<label for="email">Email :</label>&nbsp;&nbsp;user.email
<input type="text" name="edit_email" class="form-control" id="email" value=user.email ngModel>
</div>
<div class="form-group">
<label for="bio">Bio :</label>&nbsp;&nbsp;edit_bio
<input type="text" name="edit_bio" class="form-control" id="bio" value="Put who you are here!" ngModel>
</div>
<div class="form-group">
<label for="gender">Gender</label>
<select class="form-control" id="gender" name="edit_gender" ngModel>
<option>Male</option>
<option>Female</option>
<option>Others</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Submit</button>

</fieldset>
</form>


In TypeScript File



 edit_name:String='';
edit_email:String='';
edit_bio:String='';
edit_gender:String='';
user:any=;

ngOnit()
this.authService.getuser()
.subscribe(data=>
this.user=data;

this.initiateUpdateProfile();


initiateUpdateProfile()
this.edit_name=this.user.name;
this.edit_email=this.user.email;
this.edit_bio='Something you want to tell the world';
this.edit_gender='Male';



editProfile(e)
console.log(e);




Everything is running smoothly but when i am submitting the form without even touching the form elements than edit.value is not even retaining the previous values all it is logging is empty values.










share|improve this question


























  • Try Using [ngModel]="user.name" instead of value=user.name

    – Chellappan
    Mar 28 at 7:01











  • Your code does not make sense.. ngOnIt is not a lifecycle hook. It should be ngOnInit Setting the value is not gonna work. Or you need reactive forms or you need template driven forms. Read more about it here: angular.io/guide/forms and angular.io/guide/reactive-forms

    – Sam Vloeberghs
    Mar 28 at 7:03






  • 1





    @Chellappan he probably wants two-way binding, so better to use [(ngModel)]="user.name" instead of value=user.name

    – Sam Vloeberghs
    Mar 28 at 7:04











  • Actually i am displaying the previous value in value=user.name and want to update only [(ngModel)]="edit_name" only

    – Shiva Chandel
    Mar 28 at 12:21

















0















I am making a form and want to using the previous values as "value" in the form and by using ngModel dynamically changing some properties but the the field which is not changed by the user, the property is not retaining the previous value even.



<form #edit="ngForm" (submit)="editProfile(edit.value)">
<fieldset>
<div class="form-group">
<label for="username">Username : </label>&nbsp;&nbsp;@user.username
</div>
<div class="form-group">
<label for="name">Name :</label>&nbsp;&nbsp;@user.name
<input type="text" name="edit_name" class="form-control" id="name" value=user.name ngModel>
</div>
<div class="form-group">
<label for="email">Email :</label>&nbsp;&nbsp;user.email
<input type="text" name="edit_email" class="form-control" id="email" value=user.email ngModel>
</div>
<div class="form-group">
<label for="bio">Bio :</label>&nbsp;&nbsp;edit_bio
<input type="text" name="edit_bio" class="form-control" id="bio" value="Put who you are here!" ngModel>
</div>
<div class="form-group">
<label for="gender">Gender</label>
<select class="form-control" id="gender" name="edit_gender" ngModel>
<option>Male</option>
<option>Female</option>
<option>Others</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Submit</button>

</fieldset>
</form>


In TypeScript File



 edit_name:String='';
edit_email:String='';
edit_bio:String='';
edit_gender:String='';
user:any=;

ngOnit()
this.authService.getuser()
.subscribe(data=>
this.user=data;

this.initiateUpdateProfile();


initiateUpdateProfile()
this.edit_name=this.user.name;
this.edit_email=this.user.email;
this.edit_bio='Something you want to tell the world';
this.edit_gender='Male';



editProfile(e)
console.log(e);




Everything is running smoothly but when i am submitting the form without even touching the form elements than edit.value is not even retaining the previous values all it is logging is empty values.










share|improve this question


























  • Try Using [ngModel]="user.name" instead of value=user.name

    – Chellappan
    Mar 28 at 7:01











  • Your code does not make sense.. ngOnIt is not a lifecycle hook. It should be ngOnInit Setting the value is not gonna work. Or you need reactive forms or you need template driven forms. Read more about it here: angular.io/guide/forms and angular.io/guide/reactive-forms

    – Sam Vloeberghs
    Mar 28 at 7:03






  • 1





    @Chellappan he probably wants two-way binding, so better to use [(ngModel)]="user.name" instead of value=user.name

    – Sam Vloeberghs
    Mar 28 at 7:04











  • Actually i am displaying the previous value in value=user.name and want to update only [(ngModel)]="edit_name" only

    – Shiva Chandel
    Mar 28 at 12:21













0












0








0








I am making a form and want to using the previous values as "value" in the form and by using ngModel dynamically changing some properties but the the field which is not changed by the user, the property is not retaining the previous value even.



<form #edit="ngForm" (submit)="editProfile(edit.value)">
<fieldset>
<div class="form-group">
<label for="username">Username : </label>&nbsp;&nbsp;@user.username
</div>
<div class="form-group">
<label for="name">Name :</label>&nbsp;&nbsp;@user.name
<input type="text" name="edit_name" class="form-control" id="name" value=user.name ngModel>
</div>
<div class="form-group">
<label for="email">Email :</label>&nbsp;&nbsp;user.email
<input type="text" name="edit_email" class="form-control" id="email" value=user.email ngModel>
</div>
<div class="form-group">
<label for="bio">Bio :</label>&nbsp;&nbsp;edit_bio
<input type="text" name="edit_bio" class="form-control" id="bio" value="Put who you are here!" ngModel>
</div>
<div class="form-group">
<label for="gender">Gender</label>
<select class="form-control" id="gender" name="edit_gender" ngModel>
<option>Male</option>
<option>Female</option>
<option>Others</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Submit</button>

</fieldset>
</form>


In TypeScript File



 edit_name:String='';
edit_email:String='';
edit_bio:String='';
edit_gender:String='';
user:any=;

ngOnit()
this.authService.getuser()
.subscribe(data=>
this.user=data;

this.initiateUpdateProfile();


initiateUpdateProfile()
this.edit_name=this.user.name;
this.edit_email=this.user.email;
this.edit_bio='Something you want to tell the world';
this.edit_gender='Male';



editProfile(e)
console.log(e);




Everything is running smoothly but when i am submitting the form without even touching the form elements than edit.value is not even retaining the previous values all it is logging is empty values.










share|improve this question
















I am making a form and want to using the previous values as "value" in the form and by using ngModel dynamically changing some properties but the the field which is not changed by the user, the property is not retaining the previous value even.



<form #edit="ngForm" (submit)="editProfile(edit.value)">
<fieldset>
<div class="form-group">
<label for="username">Username : </label>&nbsp;&nbsp;@user.username
</div>
<div class="form-group">
<label for="name">Name :</label>&nbsp;&nbsp;@user.name
<input type="text" name="edit_name" class="form-control" id="name" value=user.name ngModel>
</div>
<div class="form-group">
<label for="email">Email :</label>&nbsp;&nbsp;user.email
<input type="text" name="edit_email" class="form-control" id="email" value=user.email ngModel>
</div>
<div class="form-group">
<label for="bio">Bio :</label>&nbsp;&nbsp;edit_bio
<input type="text" name="edit_bio" class="form-control" id="bio" value="Put who you are here!" ngModel>
</div>
<div class="form-group">
<label for="gender">Gender</label>
<select class="form-control" id="gender" name="edit_gender" ngModel>
<option>Male</option>
<option>Female</option>
<option>Others</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Submit</button>

</fieldset>
</form>


In TypeScript File



 edit_name:String='';
edit_email:String='';
edit_bio:String='';
edit_gender:String='';
user:any=;

ngOnit()
this.authService.getuser()
.subscribe(data=>
this.user=data;

this.initiateUpdateProfile();


initiateUpdateProfile()
this.edit_name=this.user.name;
this.edit_email=this.user.email;
this.edit_bio='Something you want to tell the world';
this.edit_gender='Male';



editProfile(e)
console.log(e);




Everything is running smoothly but when i am submitting the form without even touching the form elements than edit.value is not even retaining the previous values all it is logging is empty values.







html angular forms event-handling mean-stack






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 7:14







Shiva Chandel

















asked Mar 28 at 6:50









Shiva ChandelShiva Chandel

517 bronze badges




517 bronze badges















  • Try Using [ngModel]="user.name" instead of value=user.name

    – Chellappan
    Mar 28 at 7:01











  • Your code does not make sense.. ngOnIt is not a lifecycle hook. It should be ngOnInit Setting the value is not gonna work. Or you need reactive forms or you need template driven forms. Read more about it here: angular.io/guide/forms and angular.io/guide/reactive-forms

    – Sam Vloeberghs
    Mar 28 at 7:03






  • 1





    @Chellappan he probably wants two-way binding, so better to use [(ngModel)]="user.name" instead of value=user.name

    – Sam Vloeberghs
    Mar 28 at 7:04











  • Actually i am displaying the previous value in value=user.name and want to update only [(ngModel)]="edit_name" only

    – Shiva Chandel
    Mar 28 at 12:21

















  • Try Using [ngModel]="user.name" instead of value=user.name

    – Chellappan
    Mar 28 at 7:01











  • Your code does not make sense.. ngOnIt is not a lifecycle hook. It should be ngOnInit Setting the value is not gonna work. Or you need reactive forms or you need template driven forms. Read more about it here: angular.io/guide/forms and angular.io/guide/reactive-forms

    – Sam Vloeberghs
    Mar 28 at 7:03






  • 1





    @Chellappan he probably wants two-way binding, so better to use [(ngModel)]="user.name" instead of value=user.name

    – Sam Vloeberghs
    Mar 28 at 7:04











  • Actually i am displaying the previous value in value=user.name and want to update only [(ngModel)]="edit_name" only

    – Shiva Chandel
    Mar 28 at 12:21
















Try Using [ngModel]="user.name" instead of value=user.name

– Chellappan
Mar 28 at 7:01





Try Using [ngModel]="user.name" instead of value=user.name

– Chellappan
Mar 28 at 7:01













Your code does not make sense.. ngOnIt is not a lifecycle hook. It should be ngOnInit Setting the value is not gonna work. Or you need reactive forms or you need template driven forms. Read more about it here: angular.io/guide/forms and angular.io/guide/reactive-forms

– Sam Vloeberghs
Mar 28 at 7:03





Your code does not make sense.. ngOnIt is not a lifecycle hook. It should be ngOnInit Setting the value is not gonna work. Or you need reactive forms or you need template driven forms. Read more about it here: angular.io/guide/forms and angular.io/guide/reactive-forms

– Sam Vloeberghs
Mar 28 at 7:03




1




1





@Chellappan he probably wants two-way binding, so better to use [(ngModel)]="user.name" instead of value=user.name

– Sam Vloeberghs
Mar 28 at 7:04





@Chellappan he probably wants two-way binding, so better to use [(ngModel)]="user.name" instead of value=user.name

– Sam Vloeberghs
Mar 28 at 7:04













Actually i am displaying the previous value in value=user.name and want to update only [(ngModel)]="edit_name" only

– Shiva Chandel
Mar 28 at 12:21





Actually i am displaying the previous value in value=user.name and want to update only [(ngModel)]="edit_name" only

– Shiva Chandel
Mar 28 at 12:21












1 Answer
1






active

oldest

votes


















0
















 <div class="form-group">
<label for="name">Name :</label>&nbsp;&nbsp;@user.name
<input type="text" name="edit_name" class="form-control" id="name" [(ngModel)]="edit_name" value=user.name>
</div>





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%2f55391680%2fhow-to-use-the-value-of-the-forms-components-which-are-unchanged-using-ngmodel%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
















     <div class="form-group">
    <label for="name">Name :</label>&nbsp;&nbsp;@user.name
    <input type="text" name="edit_name" class="form-control" id="name" [(ngModel)]="edit_name" value=user.name>
    </div>





    share|improve this answer





























      0
















       <div class="form-group">
      <label for="name">Name :</label>&nbsp;&nbsp;@user.name
      <input type="text" name="edit_name" class="form-control" id="name" [(ngModel)]="edit_name" value=user.name>
      </div>





      share|improve this answer



























        0














        0










        0









         <div class="form-group">
        <label for="name">Name :</label>&nbsp;&nbsp;@user.name
        <input type="text" name="edit_name" class="form-control" id="name" [(ngModel)]="edit_name" value=user.name>
        </div>





        share|improve this answer













         <div class="form-group">
        <label for="name">Name :</label>&nbsp;&nbsp;@user.name
        <input type="text" name="edit_name" class="form-control" id="name" [(ngModel)]="edit_name" value=user.name>
        </div>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 28 at 12:24









        Shiva ChandelShiva Chandel

        517 bronze badges




        517 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%2f55391680%2fhow-to-use-the-value-of-the-forms-components-which-are-unchanged-using-ngmodel%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

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현