Show an HTML string in a view with a read-only formatted text display

When receiving text from my angular controller to display in the view, I want it to appear as formatted text instead of raw HTML. To achieve this, I am using the following code snippet which currently outputs a read-only textarea displaying the html tags:

<div class="well" ng-repeat="field in model.viewFields">
    {{field.Name}} 
    <textarea disabled="true" style="height: 200px; width: 100%; resize: none">{{field.Value}}</textarea>
</div>

What is an alternative element or approach that could be used in place of the textarea to properly render the {{field.Value}} HTML as formatted text?

Answer №1

Just a heads up for the future, cyrbil mentioned that angulars sanitize function actually processes the HTML automatically.

If you want to implement this feature, you can utilize ng-bind-html:

<div class="well" ng-repeat="field in model.viewFields">
    {{field.Name}} 
<div ng-bind-html="field.Value" style="height: 200px; width: 100%;"></div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for setting a uniform width for all bars in apexcharts bar column width

When working with dynamic data, the length of the data should also be variable. For instance, if the data has a length of 24, the column width should be 35px; similarly, even if the data has a length of 2, the column width should still be 35px. Apexchart ...

In HTML, an important concept to understand is how float:left is necessary when the combined widths of child blocks equal

Apologies if my question seems redundant, I was having trouble finding the right search terms. Let's discuss a scenario with a parent <div> containing two inline-block children, each with a width of 50%. If we don't apply overflow: hidden ...

Creating a popover component in Angular can be achieved by utilizing Angular Material's

I'm currently working with Angular and OpenLayers, following the example provided in this link: https://openlayers.org/en/latest/examples/overlay.html The example includes the following code snippet: var element = popup.getElement(); var ...

Enhancing the mouse pointer in a JAVA application

Currently, I am immersed in a school project and trying to capture the attention of children by implementing a unique feature - a special mouse pointer. Imagine a pointer that moves, causing a small bird to follow its every movement. My project is based ...

Unlocking the Power of $http and Stream Fusion

I'm interested in accessing the public stream of App.net. However, when I attempt to retrieve it using a simple $http.get(), I only receive one response. $http .get('https://alpha-api.app.net/stream/0/posts/stream/global') .success(func ...

Finding the correct path for the background-image URL in VueJS has been a challenge

Currently, I am learning VueJs and have encountered a roadblock in my journey. The issue I am facing is determining the correct path to specify for the URL of the background-image property in the CSS section of my component. <template> <div cla ...

Getting an alert message upon clicking an element in angularjs

I am a beginner in AngularJS and I am attempting to make some DOM modifications when a button/element is clicked. Initially, I'm just looking for guidance on how to achieve the same output as seen in this fiddle link using Angular. Can anyone assist m ...

Steps for creating a Pure CSS Scroll-to-Top button

Looking to create a Pure CSS Scroll to top, I attempted it but struggled with making it clickable like in JavaScript. Here is the CSS code I tried: body { height: 99999999999999999999999999999999999px; position: relative; } button { color: white; ...

Having Issues with Cms Installation

I've been experimenting with a content management system that I plan to use for a project, but I encountered some errors. It seems like any "dynamic" elements are not displaying properly. Warning: mysqli::prepare() [mysqli.prepare]: (42S02/1146): Tab ...

What's the key ingredient I need to add for a dropdown navigation menu?

What am I overlooking in my HTML and CSS coding to create a standard list dropdown in my navigation menu? When I preview this section of the page in Chrome and IE, the navigation area appears fine until I hover over the Fishing and Guides link. Instead of ...

Updating CSS class within a div tag utilizing ASP.NET (C#)

How can I dynamically update the properties of a CSS class using C#? I need to change the background image, font size, font style, and font based on user input through an interface. Once the changes are saved, I store them in a database. However, when the ...

Accessing a shared variable across controllers in angular.js

Looking for some advice - I'm a beginner in angular and I want to know how to pass a variable between controllers. Here's the code I am using: Main.js: function MainCntl($scope) { ---code } function SearchCtrl($scope, $http) { $scope.url ...

What could be causing my fixed header to disappear in Safari 5?

I am experiencing a strange issue with my fixed header on Safari 5 for iPad. The header disappears once it scrolls down to a certain point, even though it works fine in IE, Firefox, Chrome, and the latest version of Safari. Has anyone else encountered this ...

What steps do I need to take to develop a feature similar to Tabzilla?

Exploring the innovative navigation bar on Mozilla.org seems intriguing; commonly referred to as tabzilla, it smoothly moves down to reveal the menu at the top of the page. I wonder if there are any existing libraries or ready-made jQuery code snippets tha ...

Trouble with vertical alignment and height in a floating division

After scouring through numerous discussions on Stackoverflow regarding vertical alignment and 100% height issues, we have not found a solution. Some of the topics we explored include: Vertical-align middle not working in CSS How to fill height of a float ...

Utilize Angular filters to make $http requests for data in your controller or service

It is considered best practice to use a service that returns information of an HTTP call as a promise, with this information being added to the scope in the controller. For example: awesomeService.getAllInformation().then(data){ $scope.data = data; } T ...

Creating a Self Closing Alert Message in AngularJS: A Step-by-Step Guide

Just getting started with AngularJS and looking to create a self-closing message. How can this be accomplished? I'm aiming for similar results as the question found here: How to Automatically Close Alerts using Twitter Bootstrap However, I want to ...

Keep the columns at a full 100% height while accommodating dynamic content

Is it possible to have a two-column layout, where one column remains static while the other dynamically generates content, while ensuring both columns are 100% the height of the wrapper? https://jsfiddle.net/t1h4vngv/1/ HTML <div class="wrapper"> ...

Unable to obtain return value in AngularJS controller or view

I have been working on a geolocation and reverse geocoding application. I have a function that is triggered by a button click to call a function in my controller which then calls my service. While the service is able to retrieve values, I am unable to get ...

Border for status input like on Facebook

I tried to investigate with Firebug, but struggled to find a solution. How does Facebook wrap the border around the autosize input in the status section? I am particularly curious about the small triangle attached to the border. While using Firebug, I loca ...