[SEBA-136] Resetting default feedback config when xosForm is removed

Change-Id: I18641b05001fa6b55e7976ae85695c5865571933
diff --git a/src/app/core/form/form.spec.ts b/src/app/core/form/form.spec.ts
index 1be9a43..e0180b6 100644
--- a/src/app/core/form/form.spec.ts
+++ b/src/app/core/form/form.spec.ts
@@ -175,6 +175,13 @@
       compileElement();
     }));
 
+    it('should reset the feedback state $onDestroy', () => {
+      isolatedScope.config.feedback = 'foo';
+      expect(isolatedScope.config.feedback).toEqual('foo');
+      isolatedScope.$onDestroy();
+      expect(isolatedScope.config.feedback).toEqual(isolatedScope.hideFeedback);
+    });
+
     it('should render 4 input field', () => {
       // boolean and select are in the form model, but are not input
       expect(Object.keys(isolatedScope.config.inputs).length).toEqual(6);
diff --git a/src/app/core/form/form.ts b/src/app/core/form/form.ts
index 1c10c33..fa54c6f 100644
--- a/src/app/core/form/form.ts
+++ b/src/app/core/form/form.ts
@@ -72,19 +72,28 @@
 }
 
 class FormCtrl {
-  $inject = ['$onInit', '$scope', 'XosFormHelpers'];
+  $inject = ['$onInit', '$onDestroy', '$scope', 'XosFormHelpers', '$log'];
 
   public ngModel: any;
   public formField: any;
   private config: any;
 
+  private hideFeedback: IXosFeedback = {
+    show: false,
+    message: 'Form submitted successfully !!!',
+    type: 'success',
+    closeBtn: true
+  };
+
   constructor (
     private $scope: ng.IScope,
+    private $log: angular.ILogService,
     private XosFormHelpers: IXosFormHelpersService
   ) {
   }
 
   $onInit() {
+    this.$log.debug('[xosForm] Init component');
     if (!this.config) {
       throw new Error('[xosForm] Please provide a configuration via the "config" attribute');
     }
@@ -99,12 +108,7 @@
 
     // NOTE needed to avoid xosAlert throw an error
     if (!this.config.feedback) {
-      this.config.feedback =  {
-        show: false,
-        message: 'Form submitted successfully !!!',
-        type: 'success',
-        closeBtn: true
-      };
+      this.config.feedback =  this.hideFeedback;
     }
 
     // remove excluded inputs
@@ -112,6 +116,11 @@
       _.remove(this.config.inputs, i => this.config.exclude.indexOf(i.name) > -1);
     }
   }
+
+  $onDestroy() {
+    this.$log.debug('[xosForm] Destroying component');
+    this.config.feedback =  this.hideFeedback;
+  }
 }
 
 export const xosForm: angular.IComponentOptions = {