Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Binding to "disabled" attribute fails on IE7/8 #351

Closed
idosela opened this issue May 25, 2011 · 6 comments
Closed

Binding to "disabled" attribute fails on IE7/8 #351

idosela opened this issue May 25, 2011 · 6 comments
Assignees

Comments

@idosela
Copy link

idosela commented May 25, 2011

The following markup will make the button enabled on Chrome/Firefox but not on IE:

<body ng:init="scope = { isDisabled: false }">

  <button disabled="{{scope.isDisabled}}">Disabled</button>

</body>
@ghost ghost assigned mhevery May 25, 2011
@mhevery
Copy link
Contributor

mhevery commented May 25, 2011

This is a known issue, and I already have a fix for it in my private branch.

The issue is that the older browser do not preserve the value boolean attributes such as disabled. This prevents the angular compiler from correctly retrieving the binding expression. This is not a bug per say, but angular should have a good answer.

workaround

use ng:bind-attr

<body ng:init="scope = { isDisabled: false }">
  <button ng:bind-attr="{ disabled:'{{scope.isDisabled}}' }">Disabled</button>
</body>

proposed fix

prefix disabled with ng: to convert it into regular attribute.

<body ng:init="scope = { isDisabled: false }">
  <button ng:disabled="{{scope.isDisabled}}">Disabled</button>
</body>

@psyho
Copy link

psyho commented May 26, 2011

I think the fix should look more like (to be consistent with ng:class, ng:click, etc.):

<body ng:init="scope = { isDisabled: false }">
  <button ng:disabled="scope.isDisabled">Disabled</button>
</body>

@mhevery
Copy link
Contributor

mhevery commented May 26, 2011

@psyho

The ng:disabled should behave the same way as disabled (on non-ie browsers). Therefore the {{}} is needed. Similarly ng:href behaves same as href but it just does not make a bogus browser request. That way the developer can just add the ng: prefix.

@IgorMinar
Copy link
Contributor

where is this fix? can it be merged into master?

@mhevery
Copy link
Contributor

mhevery commented Jun 5, 2011

It is in a half baked CL. Here is the patch

src/markups.js

@@ -134,7 +134,10 @@ angularTextMarkup('option', function(text, textNode,
parentElement){

*/

var NG_BIND_ATTR = 'ng:bind-attr';

-var SPECIAL_ATTRS = {'ng:src': 'src', 'ng:href': 'href'};

+var SPECIAL_ATTRS = {};

+forEach(

  • 'src,href,checked,disabled,multiple,readonly,selected'.split(','),
  • function(name){ SPECIAL_ATTRS['ng:' + name] = name; });

angularAttrMarkup('{{}}', function(value, name, element){

// don't process existing attribute markup

if (angularDirective(name) || angularDirective("@" + name)) return;

On Thu, Jun 2, 2011 at 11:58 AM, IgorMinar <
[email protected]>wrote:

where is this fix? can it be merged into master?

Reply to this email directly or view it on GitHub:
#351 (comment)

@davidchang
Copy link
Contributor

Volunteer

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants