0

I'm using Angular Straph Modal to change user's password, I defined 2 empty variables, and when user clicks on the button change it call a function and send parameters to our API, but for some reason it's not working, if I place the same inputs with the same variables and functions outside the modal it does data binding without problems, I've checked the Modal $scope and it works but for some reason I can't get data filled by the user and I'm always getting null instead of users value.

Here's my HTML.

    <div class="u-Basic-Modal--body">
        <div class="form-group">
            <label>Contraseña Actual:</label>
            <input type="password" class="form-control" ng-model="oldPassword"/>
            {{ oldPassword }}
        </div>
        <div class="form-group">
            <label>Nueva Contraseña:</label>
            <input type="password" class="form-control" ng-model="newPassword"/>
            {{ newPassword }}
        </div>
    </div>
        <div class="u-Basic-Modal--footer text-right">
            <button class="u-Basic-Modal--button cancel" ng-click="$hide()">Cancelar</button>
            <button class="u-Basic-Modal--button success" ng-click="changePassword()">Aplicar</button>
        </div>

My controller.

app.controller('usersProfileCtrl', ['$scope', 'apiService', '$rootScope', 'userResolution', 'statusBarService',
    '$modal', function($scope, apiService, $rootScope, userResolution, statusBarService, $modal) {

        $scope.user = $rootScope.userData;
        $scope.newPassword = null;
        $scope.oldPassword = null;

        userResolution().then(function() {
            if ($scope.user.firstName === null) {
                $scope.user.firstName = '';
            } if ($scope.user.lastName === null) {
                $scope.user.lastName = '';
            }
        });

        $scope.saveData = function() {
            apiService.saveUser($scope.user).success(function() {
                apiService.getUser($scope.user.id).success(function(response) {
                    statusBarService.showNote('LABEL_DONE', true);
                    $scope.user = response.data;
                });
            });
        };

        var importsModal = $modal({
            scope: $scope,
            template: 'components/administration/users/changepassword-tpl.html',
            show: false
        });

        $scope.setPassword = function() {
            importsModal.$promise.then(importsModal.show);
        };

        $scope.changePassword = function() {
            apiService.changeUserPassword($scope.user, $scope.newPassword, $scope.oldPassword)
                .success(function() {
                    importsModal.hide();
                });
        };
}]);

Hope you guys can help me. Regards!

beaver
  • 17,333
  • 2
  • 40
  • 66
Alex
  • 879
  • 2
  • 10
  • 20
  • 1
    "Angular Straph", is this correct? Where can one find the library? Your `ng-model`s do not have a dot, did you already check that this is not the reason to your problem (see http://stackoverflow.com/questions/17606936/angularjs-dot-in-ng-model)? – masa Dec 15 '15 at 19:52
  • here is a plunker (http://plnkr.co/edit/wuvrUfA2fitf5jKgavOJ?p=preview) from your code, could you complete it? – beaver Dec 16 '15 at 12:38
  • i have debugged your code, missing jquery, add the code to your index.html: '' – Python Basketball Jan 19 '16 at 03:15

0 Answers0