easyFormGenerator icon indicating copy to clipboard operation
easyFormGenerator copied to clipboard

Toaster [$sce:itype] issue again in 2.3.0 version

Open joweste opened this issue 7 years ago • 0 comments

Version

2.3.0

Directive

  • [x ] stepway
  • [ ] formViewer
  • [ ] dragdropway

Steps to reproduce

  1. Execute the demo : "Easy for generator step way version"
  2. Fill data in design editor
  3. try to save The toast message appears on screen correctly but I get the next error in console: Error: [$sce:itype] Attempted to trust a non-string value in a content requiring a string: Context: html

I have add bodyOutputType: 'trustedHtml' at function saveThisForm() but without success.

I debugged eda.stepway.js code and It seems something is calling this code from Toast component two times: //from toaster.js

if (toast.showCloseButton) {
     toast.closeHtml = $sce.trustAsHtml(toast.closeHtml || scope.config.closeHtml);
}

So, toast.closeHtml is being trusted two times. The second time issues the error.

If I put showCloseButton: false into saveThisForm() no problem appears.

//saveThisForm() from eda.stepway.js

value: function saveThisForm() {
	      if (typeof this.configuration.formName === 'undefined') {
	        this.toaster.pop({
	          type: 'warning',
	          timeout: 2000,
	          title: 'Form name is undefined',
	          body: 'Form has not been saved.',
	          showCloseButton: true
	        });
	        return false;
	      }
	
	      if (this.configuration.formName === '') {
	        this.toaster.pop({
	          type: 'warning',
	          timeout: 2000,
	          title: 'Form name is required',
	          body: 'Form has not been saved.',
	          showCloseButton: true
	        });
	        return false;
	      }
	
	      this.toaster.pop({
	        type: 'wait',
	        timeout: 3000,
	        title: ': Form is being saved',
	        body: '',
               bodyOutputType: 'trustedHtml',   ///I add it but no results 
	        showCloseButton: true
	      });
	      // this.toaster.clear();
	      this.returnSaveEvent = true;
	
	      return true;
	    }

Expected behavior

The error stops to appears

Actual behavior

I get the next error:

angular.js:14328 Error: [$sce:itype] Attempted to trust a non-string value in a content requiring a string: Context: html
http://errors.angularjs.org/1.6.1/$sce/itype?p0=html
    at http://localhost/lib/angular/angular.js:68:12
    at trustAs (http://localhost/lib/angular/angular.js:18787:15)
    at Object.sce.(anonymous function) [as trustAsHtml] (http://localhost/lib/angular/angular.js:19543:16)
    at addToast (http://localhost/lib/angular-toaster/toaster.js:362:56)
    at Array.scope._onNewToast (http://localhost/lib/angular-toaster/toaster.js:451:33)
    at http://localhost/lib/angular-toaster/toaster.js:165:68
    at Scope.$emit (http://localhost/lib/angular/angular.js:18225:33)
    at Object.pop (http://localhost/lib/angular-toaster/toaster.js:113:32)
    at edaStepWayEasyFormGenController.saveThisForm (http://localhost/lib/easyFormGenerator/dist/eda.stepway.js:5891:21)
    at fn (eval at compile (http://localhost/lib/angular/angular.js:15156:15), <anonymous>:4:168)

joweste avatar Dec 11 '17 02:12 joweste