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

src: bind scope as ctx of onchange and validators #714

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"David Jensen <[email protected]>",
"Cameron Edwards",
"Mike Marcacci",
"Denis Dervisevic <[email protected]>"
"Denis Dervisevic <[email protected]>",
"Tristian Flanagan <[email protected]>"
],
"moduleType": [
"globals"
Expand Down
4 changes: 2 additions & 2 deletions dist/schema-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -1912,7 +1912,7 @@ angular.module('schemaForm').directive('sfChanged', function() {
if (form && form.onChange) {
ctrl.$viewChangeListeners.push(function() {
if (angular.isFunction(form.onChange)) {
form.onChange(ctrl.$modelValue, form);
form.onChange.call(scope, ctrl.$modelValue, form);
} else {
scope.evalExpr(form.onChange, {'modelValue': ctrl.$modelValue, form: form});
}
Expand Down Expand Up @@ -2801,7 +2801,7 @@ angular.module('schemaForm').directive('schemaValidate', ['sfValidator', '$parse
// Check if our version of angular has validators, i.e. 1.3+
if (form[attr] && ngModel[attr]) {
angular.forEach(form[attr], function(fn, name) {
ngModel[attr][name] = fn;
ngModel[attr][name] = fn.bind(scope);
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion dist/schema-form.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/directives/changed.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ angular.module('schemaForm').directive('sfChanged', function() {
if (form && form.onChange) {
ctrl.$viewChangeListeners.push(function() {
if (angular.isFunction(form.onChange)) {
form.onChange(ctrl.$modelValue, form);
form.onChange.call(scope, ctrl.$modelValue, form);
} else {
scope.evalExpr(form.onChange, {'modelValue': ctrl.$modelValue, form: form});
}
Expand Down
2 changes: 1 addition & 1 deletion src/directives/schema-validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ angular.module('schemaForm').directive('schemaValidate', ['sfValidator', '$parse
// Check if our version of angular has validators, i.e. 1.3+
if (form[attr] && ngModel[attr]) {
angular.forEach(form[attr], function(fn, name) {
ngModel[attr][name] = fn;
ngModel[attr][name] = fn.bind(scope);
});
}
});
Expand Down