无法解析AngularJS中的HTML

时间:2017-06-22 03:19:10

标签: javascript angularjs angularjs-directive

当我使用这个{{job.description}}时,我将其作为输出:

<p><strong><span style="text-decoration: underline;">Core Responsibilities</span> :</strong></p>
 <p> </p>
 <div class="O0">•Service level assurance</div>
 <div class="O0">•Resolution of all franchise related issues</div>
 <div class="O0">•Engage with the franchise through weekly meetings, proactive emails, and newsletters</div>
 <div class="O0">•Franchise management</div>
 <div class="O0">•Drive franchise business growth</div>
 <div>•CSAT Target achievement and delivery of actions to improve service</div>
 <div class="O0">•Ongoing Feedback and VOC on process improvement.</div>
 <div class="O0">•Escalation analysis and improvements</div>
 <div class="O0">•Increase customer satisfaction by understanding business needs and providing additional solutions and resources.</div>
 <div class="O0">•Work with customers to establish critical goals, or other key performance indicators and aid the customer in achieving their goals.</div>
 <p> </p>
 <p><span style="text-decoration: underline;">Qualifications</span> :</p>
 <p>Education :  </p>
 <div>•Graduate </div>
 <p>Years of experience : 2-3</p>
 <p>Professional attributes :</p>
 <div>•Needs proactiveness and anticipation to understand customers' problems.</div>
 <div>•Adaptability to customer’s need and requirement.</div>
 <div>•Should be a problem solver</div>
 <p>Personal attributes :</p>
 <div>•We are looking for go-getters, with high drive and ownership.</div>
 <div>•Candidate should have good communication and listening skills</div>
 <p>Locations:</p>
 <p>Gurgaon</p>

所以我尝试使用$sce过滤器,按照许多人的建议:

myApp.filter('unsafe', function($sce) {
    return function(val) {
        return $sce.trustAsHtml(val);
    };
});

HTML

<div ng-bind-html="job.description | unsafe"></div>

现在输出如下:

<p><strong><span style="text-decoration: underline;">Core Responsibilities</span> :</strong></p> <p>&nbsp;</p> <div class="O0">&bull;Service level assurance</div> <div class="O0">&bull;Resolution of all franchise related issues</div> <div class="O0">&bull;Engage with the franchise through weekly meetings, proactive emails, and newsletters</div> <div class="O0">&bull;Franchise management</div> <div class="O0">&bull;Drive franchise business growth</div> <div>&bull;CSAT Target achievement and delivery of actions to improve service</div> <div class="O0">&bull;Ongoing Feedback and VOC on process improvement.</div> <div class="O0">&bull;Escalation analysis and improvements</div> <div class="O0">&bull;Increase customer satisfaction by understanding business needs and providing additional solutions and resources.</div> <div class="O0">&bull;Work with customers to establish critical goals, or other key performance indicators and aid the customer in achieving their goals.</div> <p>&nbsp;</p> <p><span style="text-decoration: underline;">Qualifications</span> :</p> <p>Education : &nbsp;</p> <div>&bull;Graduate&nbsp;</div> <p>Years of experience : 2-3</p> <p>Professional attributes :</p> <div>&bull;Needs proactiveness and anticipation to understand customers' problems.</div> <div>&bull;Adaptability to customer&rsquo;s need and requirement.</div> <div>&bull;Should be a problem solver</div> <p>Personal attributes :</p> <div>&bull;We are looking for go-getters, with high drive and ownership.</div> <div>&bull;Candidate should have good communication and listening skills</div> <p>Locations:</p> <p>Gurgaon</p>

它解析了HTML但是在一个全新的水平上!知道我哪里错了吗?我也尝试了ngSanitize并遇到了同样的问题。我的智慧结束了。

0 个答案:

没有答案