Displaying SVGs in the <object> tag within an Angular 2 component is not functioning properly in Internet Explorer

When embedding an SVG within an <object> tag, it is not displayed in IE 11 and Edge. Instead, they only show the innerHTML as "SVG no supported," giving the impression that the tag is not supported at all.

Interestingly enough, both browsers do display embedded SVGs when not used alongside Angular components. This behavior may be related to Angular's shadowRoot emulation, as IE does not currently support Shadow DOM (IE doesn't support Shadow DOM yet)

Strangely, if I switch on IE 10 emulation within IE 11, the SVG appears properly.


Source code: http://plnkr.co/edit/ZKRIMans0qgXVyRkjKcP?p=preview

app.component.ts

import {Component} from 'angular2/core';

@Component({
    selector: 'my-app',
    template: '<object data="https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg" type="image/svg+xml">SVG not supported</object>'
})
export class AppComponent { }

main.ts:

import {bootstrap}    from 'angular2/platform/browser';
import {AppComponent} from './app.component';

bootstrap(AppComponent);

index.html:

<!DOCTYPE html>
<html>
  <head>
    <title>Angular 2 QuickStart</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">    
    <link rel="stylesheet" href="styles.css">

    <!-- 1. Load libraries -->
    <!-- IE required polyfills, in this exact order -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.0/es6-shim.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.20/system-polyfills.js"></script>
    <script src="https://npmcdn.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="70111e17051c11024230425e405e405d121504115e49">[email protected]</a>/es6/dev/src/testing/shims_for_IE.js"></script>   

    <script src="https://code.angularjs.org/2.0.0-beta.9/angular2-polyfills.js"></script>
    <script src="https://code.angularjs.org/tools/system.js"></script>
    <script src="https://npmcdn.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="394d40495c4a5a4b50494d79081701170b">[email protected]</a>/lib/typescript.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.9/Rx.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.9/angular2.dev.js"></script>

    <!-- 2. Configure SystemJS -->
    <script>
      System.config({
        transpiler: 'typescript', 
        typescriptOptions: { emitDecoratorMetadata: true }, 
        packages: {'app': {defaultExtension: 'ts'}} 
      });
      System.import('app/main')
            .then(null, console.error.bind(console));
    </script>
  </head>

  <!-- 3. Display the application -->
  <body>
    <my-app>Loading...</my-app>
  </body>
</html>


<!-- 
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
-->

Answer №1

It appears to be functioning correctly in all scenarios except when used in Plunker. The code runs without issue when executed from platforms like Visual Studio or deployed on a live server.

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

The IE browser consistently retrieves outdated data from its cache

I always encounter the issue of IE browser loading old data from the browser history. To ensure that I am getting the latest data, I consistently need to clear the browser history. Is there a way to consistently load new data without having to manually cl ...

Dual Networked Socket.IO Connection

I have set up a node.js server with an angular.js frontent and I am facing a problem with Socket.IO connections. The issue arises when double Socket.IO connections open, causing my page to hang. var self = this; self.app = express(); self.http = http.Ser ...

What is the process of defining a route for a JSON response in an Express application?

I've been following an Angular tutorial on handling form submissions with promises, which I found here. My server is running on Node and I'm using Express to manage routes. However, when I submit the form and reach the line var $promise = $http. ...

Utilize the drag-and-drop feature on an HTML5 canvas

When I drag an HTML element and drop it onto a canvas, the object is supposed to appear at the same location on the canvas where it was dropped. However, it is showing up at a different location instead. You can view my code for reference. Script functio ...

Ensure that the central section of the slider remains illuminated

Looking for help with customizing my "product" slider, lightSlider. I want the middle div to always be highlighted when navigating through the slider. Here's what it looks like currently: Link to screenshot - current. My goal is to achieve this look: ...

Excellent date and time selection tool that meets the specified criteria

After testing various datetime pickers, I have yet to find one that fully meets my needs. My development setup involves AngularJS and Bootstrap for styling. However, due to Firefox's limited support for HTML5, the Angular solutions are not functionin ...

Creating a button that redirects to an external link in CodeIgniter:

Hello everyone, I'm new here and I could really use some assistance with a problem. I am trying to link the button labeled 'lihat rincian' and each row of tables to redirect to an external link like Here's a snapshot of my datatables ...

Guidelines for populating data with an array

I have the following array: const dataArr = [[15, 14, 5], [16, 10, 2], [17, 6, 13], [18, 4, 8], [19, 7, 4]]; Now, I am populating another array using the above data as shown below: for (let i=0; i<dataArr.length; i++){ newData.push(dataArr[i]); ...

Converting a String into a JSON Array

I currently have an array of JSON plots saved in MySQL. However, when I retrieve this information from the database, it is returned as a single long string. How can I convert this back into an array of JSON objects using JavaScript? My setup involves NodeJ ...

Tips for using tooltip.format() to access an array of objects in anychart.js

Having difficulty displaying an array of objects in the tooltip of an Anychart.js map. I know we can access the dataset using %[name of property in data set]. The structure of my dataset is as follows: { "country": "Austria", &q ...

The Google map shifts beyond the perceived limits of the world

Is anyone else encountering an issue with Google Maps where you can now pan beyond the poles? It used to stop at the poles before, correct? The website I'm currently working on runs a location-based query on our server every time a user pans or zooms ...

Implement the Bootstrap datetimepicker functionality for the specified div element

The date picker successfully functions when I assign the id to the input tag as shown below: <div class="col-sm-4" id="datepicker"> <input type="text" class="form-control" id="inputDate" placeholder="Date"> <span class="glyphicon gl ...

Can you provide guidance on how to increase the value within a nested object located inside an array within another object?

In my attempt to create a bot in discord.js, I am facing a challenge where I need to implement an inventory system with items that have durability. The data is stored in MongoDB Atlas and the structure of the inventory is as follows: user: { id: 'us ...

AngularJS has the ability to handle the value of one input based on the value of another input

How can I ensure that if one input has a value, the other must also be filled in AngularJS? I'm looking for the best approach to handle this requirement in an angular way. Any suggestions? Below is my code: <div class="form-group recipe_item" ng ...

Troubleshooting custom buttons error when using carousel in Nuxt app: "Flickity is not defined"

I am attempting to connect my own personalized buttons to a flickity carousel within a nuxt application. Within my carousel component, the following code is present: <template> <ClientOnly> <Flickity ref="flickit ...

Trouble displaying options in Angular JS ng-repeat

I'm currently facing an issue with populating data from a database onto a web page. Despite my efforts, I haven't been able to get it to work as intended: <div ng-controller="AnalyzerController"> <select id="Listbox" ng-model="Listof ...

SlickGrid checkbox formatter/editor experiencing issues with data consistency

Exploring the functionalities of SlickGrid'seditors/formatters, I delved into how these features could potentially alter the data object utilized for constructing the grid (as modifications within the table are usually reflected in the original data o ...

What is the best method for inserting dynamic HTML content (DIV) with JavaScript?

Can someone assist me in dynamically adding HTML content when data is returned from the server-side? I am currently using ajax/jQuery to handle server-side processing requirements. The success code section of my ajax function allows me to write HTML elemen ...

Is there a way to retrieve the form name within my directive?

In my code, I am able to retrieve the ngModel name, but now I am looking for a way to also capture the form's name that contains the element with the "validacion" directive. It is crucial for me to programmatically obtain the form's name where t ...

Adding a table within another table in AngularJS

When dealing with three columns, such as including marks after subjects and the marks also having varying numbers of rows like subjects, what adjustments should be made to the code? Learn how to add multiple rows in one column using angular ng-repeat ...