0

i'm new in AngularJS and i'm trying to update my model after that the user click on img, this is my code :

<div class="col-xs-4 text-center"><a ng-model="user.plateforme" value="ios"><img src="ios.png" class="img-circle img-responsive"></a></div>

<div class="modal-footer">
    <a href="#" data-dismiss="modal" class="btn">Close</a>
    <a href="#" class="btn btn-primary" ng-click="update(user)">Save changes</a>
</div>
      <pre>form = {{user | json}}</pre>

and my controller :

angular.module('formExample', [])
      .controller('ExampleController', ['$scope', function($scope) {
        $scope.master = {};

        $scope.update = function(user) {
          $scope.master = angular.copy(user);
        };

        $scope.reset = function() {
          $scope.user = angular.copy($scope.master);
        };

        $scope.reset();
      }]);

Can someone help me ?

1 Answer 1

1

Add ng-click. This will cause your model to automatically digest:

<img src="ios.png" class="img-circle img-responsive" ng-click="reset();">

Here I assume that you want to call $scope.reset(), but you can create whatever method you want there.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.