Skip to content

Commit d745771

Browse files
author
Sandro Tajè
committed
final fix
1 parent c1fb0b1 commit d745771

File tree

3 files changed

+18
-30
lines changed

3 files changed

+18
-30
lines changed

dist/angular-uikit.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-uikit",
3-
"version": "1.3.17",
3+
"version": "1.3.18",
44
"description": "Angular Uikit binding",
55
"main": "./dist/angular-uikit.min.js",
66
"scripts": {

src/angular-uikit.js

+16-28
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,23 @@ angular.module('angularUikit', [])
1616
.directive('ukNgSortable', ukNgSortable)
1717
.directive('ukNgNotAllowArrayDuplicate', ukNgNotAllowArrayDuplicate)
1818
.directive('hxSubmitOnEnter', hxSubmitOnEnter)
19-
.directive('isolateForm', [function () {
19+
.directive('isolateForm', function() {
2020
return {
21-
restrict: 'A',
22-
require: '?form',
23-
link: function (scope, elm, attrs, ctrl) {
24-
if (!ctrl) {
25-
return;
26-
}
27-
28-
// Do a copy of the controller
29-
var ctrlCopy = {};
30-
angular.copy(ctrl, ctrlCopy);
31-
32-
// Get the parent of the form
33-
var parent = elm.parent().controller('form');
34-
// Remove parent link to the controller
35-
parent.$removeControl(ctrl);
36-
37-
// Replace form controller with a "isolated form"
38-
ctrl.$setValidity = function (validationToken, isValid, control) {
39-
ctrlCopy.$setValidity(validationToken, isValid, control);
40-
parent.$setValidity(validationToken, true, ctrl);
41-
};
42-
ctrl.$setDirty = function () {
43-
elm.removeClass('ng-pristine').addClass('ng-dirty');
44-
ctrl.$dirty = true;
45-
ctrl.$pristine = false;
46-
};
21+
restrict: 'A',
22+
require: '?form',
23+
link: function(scope, element, attrs, formController) {
24+
if (!formController) {
25+
return;
26+
}
27+
28+
var parentForm = formController.$$parentForm; // Note this uses private API
29+
if (!parentForm) {
30+
return;
4731
}
32+
33+
// Remove this form from parent controller
34+
parentForm.$removeControl(formController);
35+
}
4836
};
49-
}]);
37+
});
5038
;

0 commit comments

Comments
 (0)