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

feat(ngSwitch): add an optional attribute ngSwitchWhenSeparator #10798

Closed
wants to merge 1 commit into from

Conversation

lgalfaso
Copy link
Contributor

Adds an optional attribute ngSwitchWhenSeparator that allows multiple tokens to match a given ngSwitchWhen.

Closes #3410
Closes #3516

@Narretz
Copy link
Contributor

Narretz commented Jan 20, 2015

Does the separator need to be customizable? Why not settle on comma?

}));


it('should be possible to use the empty string as a separators', inject(function($rootScope, $compile) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: separator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

@gkalpak
Copy link
Member

gkalpak commented Jan 20, 2015

Does the separator need to be customizable? Why not settle on comma?

@Narretz: I guess it is to enable using , in the value (not as a separator).

@lgalfaso: This might be a little farfetched, but it would be nice to allow setting the "default" separator on ng-switch (instead of having to use it on every ng-switch-when). E.g.:

<ng-switch ng-switch-separator="|">
    <ng-switch-when="a|b">A or B</ng-switch-when>
    <ng-switch-when="c|d">C or D</ng-switch-when>
    <ng-switch-when="|+$" ng-switch-separator="+">
        | or $ (local separator overwrites default)
    </ng-switch-when>
</ng-switch>

Adds an optional attribute `ngSwitchWhenSeparator` that allows multiple
tokens to match a given `ngSwitchWhen`.

Closes angular#3410
Closes angular#3516
@lgalfaso lgalfaso force-pushed the ng-switch-separator branch from f5bf1cd to 38bf8ef Compare January 20, 2015 14:32
@lgalfaso
Copy link
Contributor Author

Does the separator need to be customizable? Why not settle on comma?

this would be a breaking change (that I am trying to avoid)

This might be a little farfetched, but it would be nice to allow setting the "default" separator

if there is some interest in this PR, then we can think about adding a default separator... doing so would be relatively easy

@bricss
Copy link

bricss commented May 26, 2015

Very needed feature, please merge it down.

@petebacondarwin
Copy link
Contributor

What if we made ngSwitchWhenSeparator a directive of its own that ngSwitch could "require". This way you could specify it as an ancestor and it would affect all descendants (similar to how ngModelOptions works)

@Narretz
Copy link
Contributor

Narretz commented Sep 2, 2016

This would be pretty cool! A global configuration is probably not a good idea, because you cannot control what templates other modules might use.

@lgalfaso
Copy link
Contributor Author

lgalfaso commented Sep 2, 2016

@petebacondarwin making it another directive could give some unexpected results. Eg.

<div ng-switch="mode">
  <p ng-switch-when="a|b" ng-switch-when-separator="|"><span other-directive/></p>
  <p ng-switch-default>X</div>
</div>

if otherDirective has a ngSwitch, then it could end up using an unexpected ngSwitchWhenSeparator.

@petebacondarwin
Copy link
Contributor

@lgalfaso OK, let's leave it as it is. Shame that we traverse up past isolated scope boundaries when doing require :-)

@gkalpak
Copy link
Member

gkalpak commented Sep 7, 2016

I still believe that moving ngSwitchWhenSeparator to ngSwitch (#10798 (comment)) is better, but it LGTM.

@Narretz
Copy link
Contributor

Narretz commented Sep 8, 2016

@gkalpak Now that you say it, I think it makes sense. Although I guess that custom separators will be used quite rarely anyway (only when the default operator is a value).

@gkalpak
Copy link
Member

gkalpak commented Sep 8, 2016

What default operator?

@Narretz Narretz closed this in 0b22173 Sep 8, 2016
Narretz pushed a commit that referenced this pull request Sep 8, 2016
…SwitchWhenSeparator

Adds an optional attribute `ngSwitchWhenSeparator` that allows multiple tokens to match a given `ngSwitchWhen`.

Closes #3410
Closes #3516

Closes #10798
@Narretz
Copy link
Contributor

Narretz commented Sep 8, 2016

Yeah, there's no default value of course. Merged to both master and 1.5.x. We can put this attribute on the ngSwitch later on.

petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
…SwitchWhenSeparator

Adds an optional attribute `ngSwitchWhenSeparator` that allows multiple tokens to match a given `ngSwitchWhen`.

Closes angular#3410
Closes angular#3516

Closes angular#10798
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
…SwitchWhenSeparator

Adds an optional attribute `ngSwitchWhenSeparator` that allows multiple tokens to match a given `ngSwitchWhen`.

Closes angular#3410
Closes angular#3516

Closes angular#10798
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
…SwitchWhenSeparator

Adds an optional attribute `ngSwitchWhenSeparator` that allows multiple tokens to match a given `ngSwitchWhen`.

Closes angular#3410
Closes angular#3516

Closes angular#10798
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
…SwitchWhenSeparator

Adds an optional attribute `ngSwitchWhenSeparator` that allows multiple tokens to match a given `ngSwitchWhen`.

Closes angular#3410
Closes angular#3516

Closes angular#10798
petebacondarwin pushed a commit to petebacondarwin/angular.js that referenced this pull request Nov 21, 2016
…SwitchWhenSeparator

Adds an optional attribute `ngSwitchWhenSeparator` that allows multiple tokens to match a given `ngSwitchWhen`.

Closes angular#3410
Closes angular#3516

Closes angular#10798
petebacondarwin pushed a commit that referenced this pull request Nov 23, 2016
…SwitchWhenSeparator

Adds an optional attribute `ngSwitchWhenSeparator` that allows multiple tokens to match a given `ngSwitchWhen`.

Closes #3410
Closes #3516

Closes #10798
petebacondarwin pushed a commit that referenced this pull request Nov 24, 2016
…SwitchWhenSeparator

Adds an optional attribute `ngSwitchWhenSeparator` that allows multiple tokens to match a given `ngSwitchWhen`.

Closes #3410
Closes #3516

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

Successfully merging this pull request may close these issues.

make ng-switch-when more powerful
6 participants