diff options
Diffstat (limited to 'src/directive/form.js')
| -rw-r--r-- | src/directive/form.js | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/src/directive/form.js b/src/directive/form.js index c3e6b21d..e3b937da 100644 --- a/src/directive/form.js +++ b/src/directive/form.js @@ -33,7 +33,7 @@ function FormController($scope, name) { $scope.$on('$destroy', function(event, widget) { if (!widget) return; - if (widget.widgetId) { + if (widget.widgetId && form[widget.widgetId] === widget) { delete form[widget.widgetId]; } forEach(errors, removeWidget, widget); @@ -60,6 +60,12 @@ function FormController($scope, name) { form.pristine = false; }); + $scope.$on('$newFormControl', function(event, widget) { + if (widget.widgetId && !form.hasOwnProperty(widget.widgetId)) { + form[widget.widgetId] = widget; + } + }); + // init state form.dirty = false; form.pristine = true; @@ -95,26 +101,6 @@ function FormController($scope, name) { } } -/** - * @ngdoc function - * @name angular.module.ng.$compileProvider.directive.form.FormController#registerWidget - * @methodOf angular.module.ng.$compileProvider.directive.form.FormController - * @function - * - * @param {Object} widget Widget to register (controller of a widget) - * @param {string=} alias Name alias of the widget. - * (If specified, widget will be accesible as a form property) - * - * @description - * - */ -FormController.prototype.registerWidget = function(widget, alias) { - if (alias && !this.hasOwnProperty(alias)) { - widget.widgetId = alias; - this[alias] = widget; - } -}; - /** * @ngdoc directive |
