Hi Guys,
thanks for replying. I tried to do this before. The code you see is above
is doing that, I just did not show the initiation of currUser. But you can
see me trying to map the values there to each field.
I guess I will try this tonight with out individually assigning each value,
just assign the entire user object.
Can ya quickly explain why this would work as opposed to the individual
assignments I am using?
i.e.
$scope.account = {
first_name : currUser.first_name,
last_name : currUser.last_name...
I take it, it has to do probably with the fact that I am setting the values
there to the specific value at THE TIME I assign it, whereas just assigning
to the entire object it flows with angular, so if I update it it will
update as well?
On Wednesday, April 30, 2014 1:21:49 AM UTC-4, Aaron Siladi wrote:
>
> Billy,
>
> Follow what Sander said then instead of
>
> value="{{ currUser.first_name }}"
>
> use:
> ng-model='currUser.first_name'
>
> Check this out: https://docs.angularjs.org/api/ng/directive/ngModel
>
> "The ngModel directive binds an input,select, textarea (or custom form
> control) to a property on the scope"
>
>
> On Tuesday, April 29, 2014 8:23:35 PM UTC-7, Billy Figueroa wrote:
>>
>> I have a question. I would like to know how people handle pre-populated
>> forms.
>>
>> I am refering to forms for an authenticated user who is a member of the
>> site. There are two types of forms in my application.
>> Registration forms (non member)
>> Account forms (members)
>>
>> I am having a design issue with my member forms. For example update your
>> user email or change your address etc
>>
>> I noticed when you populate the form using the scope variable i..e
>> <input class="span4" type="text" name="first_name" id="first_name"
>> value="{{ currUser.first_name }}">
>>
>> if I click submit on the form, none of the values are submitted
>>
>> If go another route and I decide to pre populate the values in the
>> controller then the values are always set and are never updated
>>
>> i.e.
>>
>> html
>> <input class="span4" type="text" name="first_name" id="first_name"> <---
>> no value attr, it gets value from controller below...
>>
>> javascript
>> $scope.account = {
>> first_name : currUser.first_name,
>> last_name : currUser.last_name,
>> username : currUser.username,
>> email : currUser.email,
>> phone : currUser.phone,
>> address1 : currUser.address1,
>> address2 : currUser.address2,
>> city : currUser.city,
>> state : currUser.state,
>> zipcode : currUser.zipcode,
>> country : currUser.country
>> };
>>
>>
>> I would like a nice elegant way to handle this or at least get some ideas
>> of how people are handling this. I take it I may have to use watchers of
>> some sort
>>
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.