14

I was studiously reading the AngularJS API reference for the ngSwitch directive when I came to that part :

place an expression on the on="..." attribute (or the ng-switch="..." attribute)

So of course I was wondering why there are two ways to place the expression since both of them seems to work the same way.

<div ng-switch="expression">
<div ng-switch on="expression">

I assume there is a reason but I do not find anything for now.

Plunker to test : http://plnkr.co/edit/VAq1t4744bnNC6RgZtEn?p=preview

Brain Up
  • 163
  • 2
  • 10

1 Answers1

13

There is no difference. You can check the sources of ng-switch directive https://github.com/angular/angular.js/blob/master/src/ng/directive/ngSwitch.js

var watchExpr = attr.ngSwitch || attr.on
Yurii K
  • 162
  • 1
  • 5
  • 5
    Yes, that's what I was expecting. So I just doesn't understand why there are two syntax. Not really usefull and potentially confusing :) – Brain Up Jul 22 '15 at 12:41
  • 1
    One use for the on syntax is that you can use ng-switch as a tag: `` – JusMalcolm Aug 26 '19 at 22:05