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

$interpolate 'allOrNothing' ignores empty case #15133

Closed
amitport opened this issue Sep 14, 2016 · 3 comments
Closed

$interpolate 'allOrNothing' ignores empty case #15133

amitport opened this issue Sep 14, 2016 · 3 comments

Comments

@amitport
Copy link

Do you want to request a feature or report a bug?
bug

What is the current behavior?
$interpolate service when running with allOrNothing, does not pass the value if there's nothing to interpolate (this affects ngAtrr*, which does not write the corresponding attribute when it has a simple value)

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).
http://plnkr.co/edit/1QhnA9xb5BgyzWHpeL7O?p=preview

What is the expected behavior?
should see the poster image on video...

What is the motivation / use case for changing the behavior?
Although there is no real need for using ngAttr/ngSrc/ngHref without interpolation, it's sometimes useful to do so when exploring initial html template or learning angular. Having to use ng-attr-*="{{'value'}}" instead of ng-attr-*="value" is not intuitive.

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
angular 1.5.8
win 7
chrome 53, IE 11, firefox 47

Other information (e.g. stacktraces, related issues, suggestions how to fix)
following #15130 (comment)

@Narretz
Copy link
Contributor

Narretz commented Sep 14, 2016

I think this is a valid problem, and it would be good to align this with normal attribute handling (which allows static values for obvious reasons).

@gkalpak
Copy link
Member

gkalpak commented Sep 16, 2016

I don't think this has anything to do with allOrNothing. It is because when there is no interpolation symbol, then $interpolate returns undefined, which cause the internal interpolate directive to bail out early (without setting the attribute value). It makes sense in most cases, because the attribute is already set, but in the case of ngAttr we need to explicitly set the corresponding attribute.

gkalpak added a commit to gkalpak/angular.js that referenced this issue Sep 16, 2016
…rpolation

Previoulsy, when the value of an `ngAttrXyz` attribute did not contain any interpolation, then the
`xyz` attribute was never set.

BTW, this commit adds a negligible overhead (since we have to set up a one-time watcher for
example), but it is justifiable for someone that is using `ngAttrXyz` (instead of `xyz` directly).

Fixes angular#15133
@gkalpak
Copy link
Member

gkalpak commented Sep 16, 2016

I submitted a possible fix in #15149.

gkalpak added a commit that referenced this issue Sep 25, 2016
…rpolation

Previoulsy, when the value of an `ngAttrXyz` attribute did not contain any interpolation, then the
`xyz` attribute was never set.

BTW, this commit adds a negligible overhead (since we have to set up a one-time watcher for
example), but it is justifiable for someone that is using `ngAttrXyz` (instead of `xyz` directly).

(There is also some irrelevant refactoring to remove unnecessary dependencies from tests.)

Fixes #15133

Closes #15149
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this issue Nov 21, 2016
…rpolation

Previoulsy, when the value of an `ngAttrXyz` attribute did not contain any interpolation, then the
`xyz` attribute was never set.

BTW, this commit adds a negligible overhead (since we have to set up a one-time watcher for
example), but it is justifiable for someone that is using `ngAttrXyz` (instead of `xyz` directly).

(There is also some irrelevant refactoring to remove unnecessary dependencies from tests.)

Fixes angular#15133

Closes angular#15149
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this issue Nov 21, 2016
…rpolation

Previoulsy, when the value of an `ngAttrXyz` attribute did not contain any interpolation, then the
`xyz` attribute was never set.

BTW, this commit adds a negligible overhead (since we have to set up a one-time watcher for
example), but it is justifiable for someone that is using `ngAttrXyz` (instead of `xyz` directly).

(There is also some irrelevant refactoring to remove unnecessary dependencies from tests.)

Fixes angular#15133

Closes angular#15149
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this issue Nov 21, 2016
…rpolation

Previoulsy, when the value of an `ngAttrXyz` attribute did not contain any interpolation, then the
`xyz` attribute was never set.

BTW, this commit adds a negligible overhead (since we have to set up a one-time watcher for
example), but it is justifiable for someone that is using `ngAttrXyz` (instead of `xyz` directly).

(There is also some irrelevant refactoring to remove unnecessary dependencies from tests.)

Fixes angular#15133

Closes angular#15149
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this issue Nov 21, 2016
…rpolation

Previoulsy, when the value of an `ngAttrXyz` attribute did not contain any interpolation, then the
`xyz` attribute was never set.

BTW, this commit adds a negligible overhead (since we have to set up a one-time watcher for
example), but it is justifiable for someone that is using `ngAttrXyz` (instead of `xyz` directly).

(There is also some irrelevant refactoring to remove unnecessary dependencies from tests.)

Fixes angular#15133

Closes angular#15149
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this issue Nov 21, 2016
…rpolation

Previoulsy, when the value of an `ngAttrXyz` attribute did not contain any interpolation, then the
`xyz` attribute was never set.

BTW, this commit adds a negligible overhead (since we have to set up a one-time watcher for
example), but it is justifiable for someone that is using `ngAttrXyz` (instead of `xyz` directly).

(There is also some irrelevant refactoring to remove unnecessary dependencies from tests.)

Fixes angular#15133

Closes angular#15149
petebacondarwin pushed a commit that referenced this issue Nov 23, 2016
…rpolation

Previoulsy, when the value of an `ngAttrXyz` attribute did not contain any interpolation, then the
`xyz` attribute was never set.

BTW, this commit adds a negligible overhead (since we have to set up a one-time watcher for
example), but it is justifiable for someone that is using `ngAttrXyz` (instead of `xyz` directly).

(There is also some irrelevant refactoring to remove unnecessary dependencies from tests.)

Fixes #15133

Closes #15149
petebacondarwin pushed a commit that referenced this issue Nov 24, 2016
…rpolation

Previoulsy, when the value of an `ngAttrXyz` attribute did not contain any interpolation, then the
`xyz` attribute was never set.

BTW, this commit adds a negligible overhead (since we have to set up a one-time watcher for
example), but it is justifiable for someone that is using `ngAttrXyz` (instead of `xyz` directly).

(There is also some irrelevant refactoring to remove unnecessary dependencies from tests.)

Fixes #15133

Closes #15149
ellimist pushed a commit to ellimist/angular.js that referenced this issue Mar 15, 2017
…rpolation

Previoulsy, when the value of an `ngAttrXyz` attribute did not contain any interpolation, then the
`xyz` attribute was never set.

BTW, this commit adds a negligible overhead (since we have to set up a one-time watcher for
example), but it is justifiable for someone that is using `ngAttrXyz` (instead of `xyz` directly).

(There is also some irrelevant refactoring to remove unnecessary dependencies from tests.)

Fixes angular#15133

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

Successfully merging a pull request may close this issue.

3 participants