Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Callback not working #14

Open
evanpratama opened this issue Nov 7, 2014 · 4 comments
Open

Custom Callback not working #14

evanpratama opened this issue Nov 7, 2014 · 4 comments

Comments

@evanpratama
Copy link

Hi,

I tried using your directive, but can't seem to get the Custom call back working:

HTML:

<input type="email" name="email" ng-model="user.email" ng-remote-validate="{ '/user/checkEmailValid' : 'uniqueEmail'}" />

Controller:

var registrationApp = angular.module('registrationApp',['ui.utils','remoteValidation']);
registrationApp.controller('RegistrationCtrl', function ($scope, $http, $window) {
    $scope.emailSetArgs = function( val, el, attrs, ngModel ) {
        return { test: val };
    };
});

It is always sent as { value: val } instead of { test: val }. I was thinking of sending the string straightaway without any JSON array.

Am I doing anything wrong in my code?

@enderdickerson
Copy link

+1. Same problem here.

@enderdickerson
Copy link

These lines seem to be the problem. Scope is referencing child scope instead of the parent where the callback would exist.

Adding $parent to both scope calls fixes the issue for me.

@deyan-stoynov
Copy link

+1. Same problem here.

azatoth added a commit to azatoth/ng-remote-validate that referenced this issue Apr 21, 2015
We need to check scope.$parent for the inputNameSetArgs callback
Closes webadvanced#14
@jaysonduenas
Copy link

Thanks for fixing! :)

just my two cents. What if we add ngArgs to isolated scope then we pass it in html? . With this, we don't have to worry about the parent/child scope.

FYI. I'm still new in AngularJs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants