我有一个表单html,如下所示:
<div class=\"container\">\r\n\t<div class=\"clearfix row
\">\r\n\t\t<div class=\"col-md-12 column\">\r\n\t\t\t<h3>\r\n\t\t\t\tNew form created\r\n\t\t\t<\/h3
>\r\n\t\t\t<div class=\"form-group\">\r\n\t\t\t\t <label><strong>Enter name<\/strong><\/label><input
name=\"1430985388220267#enter_name\" id=\"1430985388220267\" class=\"form-control\" grid-name=\"Enter
name\" type=\"text\" \/>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t<\/div>\r\n<\/div>
我想在移动应用程序中显示此表单。我已经在离子框架和Cordova中开发了带有角度JS的移动应用程序。当我尝试将表单显示为html时,它将使用诸如标头,粗体,内容之类的基本元素来呈现,但未显示输入标签,否则我可以说html的基本数据输入元素(如复选框,单选按钮)等不显示。我正在这样做:
<ion-view title="Fill the Form">
<ion-content class="padding-vertical" ng-repeat="htmlValue in HTML">
<div ng-bind-html="getHtml(htmlValue)">
</div>
{{htmlValue}}
<div class="clearfix"></div>
</ion-content>
</ion-view>
我的getHtml函数是这样的:
$scope.getHtml = function(html){
var trusted = $sce.trustAsHtml(html);
return trusted;
};
我也修改了:
angular.module('iot', ['ionic','chart.js','ngSanitize'])
我将代码从REST响应推送到名为的数组中 HTML
但是我仍然没有获得预期的输出,在这种情况下还剩下什么?任何帮助将不胜感激。
使用过滤器:
// Filter to enable HTML tags
app.filter('unsafe', function ($sce) {
return function (val) {
return $sce.trustAsHtml(val);
};
});
然后将其与过滤器(在这种情况下为“不安全”)一起包含在HTML标记中,例如:
<!-- i.detail will be your valuable -->
<div ng-bind-html="i.detail | unsafe"></div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句