2017-02-02 5 views
14

जब मैं एक पाठ-एचटीएमएल के रूप में मेरे डेटा दिखाने की कोशिश की, यह HTML स्वरूप में दिखाया गया है लेकिन जब मैं पृष्ठ ताज़ा किया, मैं इस त्रुटि हो रही है:कोणीयजेएस: "सुरक्षित संदर्भ में असुरक्षित मूल्य का उपयोग करने का प्रयास करने" का समाधान कैसे करें?

[$sce:unsafe] Attempting to use an unsafe value in a safe context.

यहाँ मेरी AngularJS है कोड:

data.attributes.task_name = $sce.trustAsHtml(data.attributes.task_name); 

एचटीएमएल

<span ng-bind-html="taskdata.attributes.task_name" data-html="true" title="{{reminder.attributes.message}}"></span> 
+0

क्या [मेरा उत्तर] (http://stackoverflow.com/a/41997335/4927984) ने आपकी समस्या हल की है? – Mistalis

उत्तर

31

से:

The value provided for use in a specific context was not found to be safe/trusted for use.

AngularJS's Strict Contextual Escaping (SCE) mode (enabled by default), requires bindings in certain contexts to result in a value that is trusted as safe for use in such a context. (e.g. loading an AngularJS template from a URL requires that the URL is one considered safe for loading resources.)

This helps prevent XSS and other security issues. Read more at Strict Contextual Escaping (SCE)

You may want to include the ngSanitize module to use the automatic sanitizing.


आप शामिल करने के लिए ngSanitize है:

लोड यह index.html पर:

<script src="lib/angular/angular-sanitize.min.js"></script> 

अपने अनुप्रयोग में एक निर्भरता के रूप में इसकी सुई। जेएस:

angular.module('myApp', ['...', 'ngSanitize']); 
+0

यह आश्चर्यजनक था कि मुझे एंगुलरजेएस में एक लाइनब्रेक के साथ एक चरित्र में शामिल होने की अनुमति दी गई। धन्यवाद! – wickedchild

संबंधित मुद्दे