GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Angular处理Html转义问题 · Issue #5 · Wscats/articles Closed Labels Descriptionangular用$sce服务来过滤HTML标签 $scope.shareTips = data.data;//后台返回的数据赋个值吧 $scope.shareTipss = '1、Eno Yao;<br/>2、WsCats'; $scope.shareTips.rule_content = $sce.trustAsHtml($scope.shareTips.rule_content);//这里发现还是不行,难道姿势不对吗,纠结中~ console.log($scope.shareTips.rule_content);//测试返回的是空对象 $scope.shareTips.rule_content = $scope.shareTips.rule_content.replace(/\r?\n/g, "<br />");//换用正则解决,把所有\n换成<br />,是可以的 console.log($scope.shareTips.rule_content);//这里返回的字符串已经把\n换成<br />的 这里有两点细节很重要: angular.module('App').controller('ShareTipsCtrl', ['$rootScope', '$scope', 'Request', '$cookies', '$window', '$routeParams', '$location', '$sce', function($rootScope, $scope, request, $cookies, $window, $routeParams, $location, $sce) { //测试$sce }]); 其次就是View渲染的时候 20160426更新 angular.module('AswsTest').controller('OrderAliPayCtrl', ['$rootScope', '$scope', 'Request', '$cookies', '$window', '$routeParams', '$location', 'Tool', '$sce', function($rootScope, $scope, request, $cookies, $window, $routeParams, $location, tool , $sce) { console.log($rootScope.alipayDom.order_string); $scope.dom = $sce.trustAsHtml($rootScope.alipayDom.order_string); } ]) <div ng-bind-html="dom"> </div> ActivityMetadataMetadataAssigneesLabelsTypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |