Why doesn't an input modify a value outside of an ng-repeat (and ng-switch)?

Viewed 3537

I am assuming a scope problem is the reason the input in this example can modify the value next to it, but not the other value. If this is the case, how do I hook up the model to right scope? If it isn't a scope problem, what am I doing wrong?

<html ng-app>
    <head>
        <script type="text/javascript" src="angular-1.0.1.min.js"></script>
        <script type="text/javascript">
            function ExampleCtrl($scope) {
                $scope.list = [
                    { name: "a" },
                    { name: "b" },
                ];

                $scope.value = 5;
            }
        </script>
    </head>
    <body ng-controller="ExampleCtrl">
        <ul ng-repeat="item in list">
            <li>{{ item.name }}
                <ng-switch on="item.name">
                    <span ng-switch-when="b">
                        <input type="number" ng-model="value" />
                        {{ value }}
                    </span>
                </ng-switch>
            </li>
        </ul>

        value is {{ value }}
    </body>
</html>
2 Answers
Related