Two-way binding does not function properly with custom directives on Internet Explorer version 9

Take a look at this unique angular application :

<!DOCTYPE html>
<html>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
  <link href="style.css" rel="stylesheet" />
  <script src="script.js"></script>
</head>

<body ng-app="app">

  <div ng-controller="someController as ctrl">
     <simple-directive item="ctrl.item" disabled="false"></simple-directive>
     <pre>{{ctrl.item | json}}</pre>
 </div>

</body>

var app = angular.module('app', []);

app.directive('simpleDirective', function() {
  return {
   scope : {
    item : '=',
    disabled : '='
  },
  template : '<input type="text" ng-model="item.value" ng-disabled="disabled" />'
 };
});

app.controller('someController', function() {
});

The angular app functions correctly on Chrome and Firefox. It successfully binds the text box value to ctrl.item.value.

However, Internet Explorer 9 does not support the two-way data binding feature.

Interestingly, if the custom directive is removed and just using the text box alone, it works fine on all browsers.

Why does IE9 have issues with the custom directive? Dive into the code further to find out.

Plunkr Demo (Note : Plunkr might not work on IE9)

Answer №1

One interesting thing to note is that disabled is an attribute, and unfortunately older browsers don't retain the value of this attribute.

This issue has been discussed here: https://github.com/angular/angular.js/issues/351

"The problem lies in the fact that older browsers fail to preserve the values of boolean attributes like disabled. This poses a challenge for the angular compiler in accurately retrieving the binding expression. While this may not be classified as a bug per se, it would be beneficial for angular to provide a solid solution."

Suggestion: Perhaps consider using data-disabled instead of relying solely on ng-disabled.

Answer №2

Consider using data-disabled="false" in place of disabled="false".

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

Transferring the values of JavaScript objects to HTML as strings

My goal is to generate HTML elements based on the values of specific JavaScript objects that are not global variables. However, when attempting to execute the code below, I encounter an error stating "params is not defined." What I actually aim to achieve ...

JavaScript's jQuery selector retrieves a child element from one location and adds it to a different

Why does the Jquery children selector select the img element, extract it, remove it, and then append it to another div element? Shouldn't it create a copy of the element being appended? var $anchors = $("#imageGallery a"); var $overlay = $('&l ...

When implementing Firebase Cloud Messaging with React, the token generated by firebase.messaging().getToken() will vary with every refresh

I'm working on a React web app using Gatsby and I want to integrate push notifications through FCM. My firebase-messaging-sw.js service worker is set up, and I'm trying to retrieve a token using the following method in my app: messaging .req ...

Server not receiving any data through Node.js Express

After searching for similar inquiries, I couldn't find anything related to this topic, so my apologies if it's already been addressed elsewhere. As someone relatively new to front-end development, I've been working on a simple personal proj ...

The existing session persists when a new user logs in, instead of being destroyed

Security measures will be implemented at a later time Currently, I have a login script that operates in two scenarios. It either returns a message in JSON format, indicating issues such as incorrect login credentials or empty fields, or it initiates a ses ...

How about this: "Unveil the beauty of dynamically loaded

var request = new Request({ method: 'get', url: 'onlinestatusoutput.html.php', onComplete:function(response) { $('ajax-content').get('tween', {property: 'opacity', duration: 'long&apos ...

Angular - the offspring of another element

I'm currently exploring the possibilities of identifying if a clicked element is a child of another using Angular. In jQuery, I would typically use has() for this task, but I'm unsure of the equivalent method in Angular aside from iterating throu ...

Is it possible to nest enums within enums in TypeScript programming?

enum TYPES { CODE = 1, TEXT, IMAGE, VIDEO } enum ALL_TYPES { CODE = 1, TEXT, IMAGE, VIDEO, NONE } Is there a way to incorporate the TYPES enum into the ALL_TYPES enum? ...

Verify the authenticity of angularjs and enroll in classes

Recently diving into the world of Angularjs, I'm pondering on the best approach to create a basic app allowing users to subscribe to courses... Where should I store these subscription records? Is saving them in a json file on the server secure enough ...

Instructions for launching an Android app from a website

Is it possible to invoke my app from HTML? For instance, I am able to successfully call a webpage from my app using this code. android code: startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse( "myDomain.com"))); ...

Difficulty encountered when applying date filtering on a specific filter in the MUI-DataGrid

Software Version: "@mui/x-data-grid": "^6.2.1" I have a script that generates columns for the DataGrid as shown below (only including relevant code) if (prop === "date" || prop === "dateModified" || prop === "n ...

Obtain the value of a URL parameter on a webpage without needing to refresh the

I have a list of records on a webpage, each with a unique URL pointing to another page with a parameter in the URL. When any of these records are clicked, I want to display the value of the URL parameter in an alert without reloading the page. <script& ...

Setting up angular-cli project for rc5- Step by step guide

Trying to integrate angular-cli with angular 2 rc5 but facing challenges: The issue of 'Promise' not being found After attempting to install 'npm install -g angular-cli@webpack', typings did not get installed, resulting in WebStorm un ...

Using a Svelte click event to toggle a boolean value in an array from a div

How can I modify the toggle functionality to work on any click event, not just on a button, in order to trigger a state change regardless of the element clicked? ToolBar.ts export default class ToolBar { options:Array<ToolBarOptions>; const ...

What is the best way to delete a parent div without losing its inherited CSS properties?

My current objective involves the following: <div id="table"> <div id="user"></div> <div id="user1"></div> </div> Upon clicking a button, the following actions take place: $("#body").append("<div id=\"user-wra ...

PHP project encountered an error stating: "Uncaught TypeError: Ajax is not a function"

I am in the process of configuring an apache server for a project using XAMPP, MySQL, and PHP 5.6 Unfortunately, it appears that there is an issue with how JavaScript has been referenced in the project, and I am unable to get it to function correctly (th ...

Diving into Discord.JS - Is there a way to check if a specific message content exists within an array?

I'm currently working on developing a Discord user verification bot that generates a 2048-bit key upon joining a server. This key will be crucial for verifying your account in case it gets compromised or stolen, ensuring that the new account belongs t ...

Tips for placing a marker at the center of the screen on Google Maps

I am developing a transportation app similar to Uber or Lyft using JavaScript. I am looking to retrieve the map location with the center of the screen, where there is a marker located at y = 0 and x = 0. Similar to the image below: The user should be abl ...

Adding or removing rows within an array in a hybrid Vue project - a step-by-step guide

Recently, I created a small web application to assist in organizing my project ideas. Check it out here: https://codepen.io/aibrindley/pen/ELXajM Now, I am working on enabling users to add items to the array directly from the interface. It would also be c ...

Iterate through and remove elements within an array containing objects

Within my Vue.js application, I am working with an array of objects that I need to iterate through and display in the web browser. The array consists of four objects, but I only wish to show three based on a user's preference setting stored in a varia ...