JSFiddle - React, Tailwind, and code Playground

by silvajeff

HTML

<body ng-app="demoApp">
    <div ng-controller="DemoController">
        <div>
            <select ng-model="selectedCaption" ng-options="caption.name for caption in captions"></select>
            <br>The item in the array selected is {{ selectedCaption.name }} but I need this to show 3 if C is chose...</div>
    </div>
</body>

JavaScript

angular.module('demoApp', []).controller('DemoController', function ($scope) {

    $scope.captions = [{
        name: 'A',
        value: 'a'
    }, {
        name: 'B',
        value: 'b'
    }, {
        name: 'C',
        value: 'c'
    }, {
        name: 'D',
        value: 'd'
    }, {
        name: 'E',
        value: 'e'
    }];

    //how could I determine that 3 should be the number used in the expression below
    $scope.selectedCaption = $scope.captions[3];
});