javascript - AngularJS text input with ng-model but needs default value not working with value= or ng-init= -
I have an account form with many inputs. One of them below:
& Lt; Input class = "form-control" placeholder = "first name" type = "text" ng-model = "account.first_name" ng-init = "account.first_name = user.account.first_name" & gt; I have a service in my controller that gives all the user information. I'm trying, in the input, show current information on the file.
I want it in an input so that they can change it.
However, when I set the value = "{{user.account.first_name}}" which returned from my service to my API and $ scope. user sets equals , nothing shows input in it. I searched for answers on SO and gave some suggestions which ng-init , which still did not work. I have also tried the ng-bind , ng-value , and before that i ng-model Setting. How do I do this?
Edit:
Here is my account administrator. Only service in return $ http.get ('/ api / account'); app.controller ('AccountCtrl', function ($ radius, account) {account.show () .success (function (data) {$ scope.user = data; There is a JSON schema: {"account": {}, "document": data {}} But from inside the data.
After receiving the data from the service, do it in the administrator
account.show () .success (data) {$ scope.user = data; // set account.first_name here $ scope. Account = {first_name: $ scope.user.account.first_name}; // or you can use angular.copy (source, destination) They are angular.copy (data. Count, $ scope.account)});
Comments
Post a Comment