Closed
Description
I was investigating issue
#198
and found that removed form element scopes and controllers continue to live and they listen to events and can break form validation. I've tested this and found that amount of living form element scopes living is proportional to form changes count.
So I've tried to $destroy() scopes of form elements before replacing them with new ones and it fixed both issues this and issue with validation(#198). I guess it would be nice to have ability at least manually destroy them via schema-form API.
Here are part of code resolving the issue
function Controller($scope, $element, service){
$scope.addressSchema = {};
$scope.addressForm = ["*"];
$scope.$watch('isoCountry', function(value){ // country code changed
service.loadForm(value).then(function (data) { // load new form json
$element.find('input,select,textarea').each(function (index, element){ // find all children inputs
var childScope = angular.element(element).scope();
if(childScope){
childScope.$destroy(); // destroy all children input scopes
}
});
... Apply new form data here
....