Removing backslashes in template interpolation with Angular 9

I am encountering a problem where I need to display a string on the page containing double backslashes "\\" but Angular is removing one of them, interpreting it as a regular expression.

You can see an example of this issue here: https://codepen.io/bental/pen/xxZdYZv

I have attempted to escape the string using DomSanitizer without success.

I prefer not to modify the data since it is generated from the backend and unpredictable.

Answer №2

Add a double backslash\\\\ in front of every single backslash\\ to represent one backslash\

This sanitizer bypasses security and trusts HTML("Double backslashes are being removed -> \\\\")

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

Guide to retrieving JSON key and value using AJAX

Is there a way for me to retrieve my json object using the table header as the key and displaying the corresponding values in an HTML table? history:{1/22/20: 2, 1/23/20: 3, 1/24/20: 5, 2/1/20: 19, 2/10/20: 32, 2/11/20: 33, 2/12/20: 33, 2/2/20: 19, 2/20/2 ...

Ignore a directory during TypeScript compilation

When writing code in Atom, the use of tsconfig.json to include and exclude folders is essential. For optimal intellisense functionality, the node_modules folder must be included. However, when compiling to js, the node_modules should not be compiled. To ac ...

Ways to display all utilized typescript types within a project

Here is a snippet of code I'm working with in my project: describe('Feature active', () => { it('Should render a Feature', () => { const wrapper = shallow(<MyComponent prop1={1}/>); expect(wrapper.prop('p ...

Experimenting with a loader component in AngularJS

This is a test for a $resource with a loader describe('Service: MultiCalculationsLoader', function(){ beforeEach(module('clientApp')); var MultiCalculationLoader, mockBackend, calculation; beforeEach(inject(function (_ ...

TypeORM Error: Trying to access the 'id' property of an undefined object

I attempted to implement migration in TypeORM as shown below: TableExample.entity.ts @Entity({ name: 'table_example' }) export class TableExampleEntity { constructor(properties : TableExampleInterface) { this.id = properties.id; ...

Save the selected value from the dropdown menu and automatically check the corresponding checkbox when it

I'm attempting to update the 'value' of a checkbox once an item is chosen from a dropdown list and then the checkbox itself is clicked. I have created a jQuery function that captures the value from the dropdown list (I omitted the code for t ...

Can anyone provide examples of how RegisterClientScriptBlock parameters are used in practical situations?

https://i.sstatic.net/dVjHt.jpg I've always struggled to grasp the true purpose of using the Control, Type, and Key in this particular class. Typically, I would use it with: this, GetType(), "xx" however, now I am determined to gain a deeper unders ...

Combining two forms into one PHP page, but intending to submit only a single form

I'm facing an issue on my page where I have both a sign-in and a sign-up form. Whenever I click on either the sign-in or sign-up button, it always ends up submitting the sign-up form. What am I doing wrong? Here's the PHP code snippet: if($_SE ...

Repeating an AJAX request overlooks the success callback function

I am facing a challenge in refreshing an AJAX call when the token expires. Although everything seems to be working fine with the implementation of ajaxSetup, I noticed that the request is not triggering the success callback as expected. $.ajax({ url: ...

Filter a two-dimensional array based on the presence of a string value found in the second array

My logic for this assignment is not very good, as I need to filter a 2D array based on the values of another array. Let me provide an example of the 2-Dimensional Array: const roles = [ ['roles', 'admin', 'write'], ['ro ...

Having Trouble with Form Submission Button Across Different Web Browsers

Having some trouble with my form - all fields are properly closed with tags, but when I click the submit button, nothing happens. The page is loaded with code, so here's the link for you to check it out. Unfortunately, right-click is disabled, so ple ...

Updating elements in a table view using Titanium

Hey there! I'm currently working on an Android application using Titanium. I've encountered a problem with changing images upon click using the code below. The issue is that the image only changes once, upon the first click. Subsequent clicks do ...

transferring double quotation marks and square brackets through a parameter

I have an angularjs (1.x) scope set up as follows: $scope.report = { resource: '/public/emplyACH', params: { "employeeId": [78] } }; When I try to access it using console.log (console.log(scope.parms)) I see the output as ...

What techniques can be used to ensure an element remains visible within the viewport

I am currently working with an HTML element that is displayed when a button is clicked, similar to a popup. My goal is to determine if the element is within the browser's viewport and then position it accordingly inside the viewport. Is there a proper ...

Tips for retrieving a nested data value within an array

I am currently puzzled by the undefined error I encounter when attempting to access a value using dot notation. The following illustrates my point: My goal is to retrieve the value from within the nested object in the headline color array: ...

Incorporating a JSON file through a script element

A customized I18n plugin has been developed to accept various languages through json files. The goal is to simplify usage for users by allowing them to easily insert their json package directly into a page along with the script: <script id="pop-languag ...

Error: An unrecognized symbol '<' was encountered while utilizing $routeparams

In my Angular application with MongoDB, Express, and Node.js, I have a list of flats and I want to add an "Edit" option for each flat. Below is a snippet from my api.js file: api.route('/flats/:id') .get(function(req, res){ Flat.findById(r ...

Pop Ups in PHP: A Guide to Retrieving Variables

I'm a beginner in PHP and I have two files named file_upload.php and test1.php. On file_upload.php, there is a button: <input type="button" value="Link More Opinion" onclick="popUp('test1.php');" /> The JavaScript for that button: & ...

Postponing the execution of a controller until all JSON files have been fully loaded

I am currently trying to grasp the concepts of AngularJS, so my question might not be perfect. Is it feasible to delay the execution of a controller until the json files are fully loaded in a separate function? Below is the controller code: app ...

Each property of an object has its own unique key, yet they all share the same data type

I have a single-use object with only three properties, all of which should be of the same type. The code below currently achieves this, but I'm curious if there is a more efficient way to declare the type for timingsObject: let timingsObject: ...