我需要獲取文本,例如在ng-bind-html
上格式化,但使用角度變量。是有點難以解釋文本形式,看是否是在此代碼和小提琴理解:在ng-bind-html中獲取打印值
var testApp = angular.module('TestApp', []);
testApp.controller('TestController', function($scope, $sce) {
$scope.wrappedValue = $sce.trustAsHtml('asdf<div>°C<br />aaa</div>'); //this is my input
var data = $scope.wrappedValue;
console.log(data); //here I want to get printed: "asdf\n°C\naaa"
});
http://jsfiddle.net/r565nb2p/3/
我很欣賞你注意閱讀本。謝謝
您可以解析'wrappedValue'來刪除HTML標籤並僅保留文本。 – Mistalis