angularjs - Searching a map and retrieving key if matching -angular js -


angular-js searching map , retrieving key if matching user given input key

my map luks this

var mymap= { k:1000, l:100000, m:1000000, c:10000000 }; if user input "l" , want search map , retrieve l along value "100000" , further operation

as mymap object (aka associative array, aka hash) can access value using [] operator.

angular.module('mymodule', [])    .controller('mycontroller', function($scope) {      $scope.mymap = { k:1000, l:100000, m:1000000, c:10000000 };      });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>    <div ng-app='mymodule' ng-controller='mycontroller'>    <input type='text' ng-model='mymapkey' />    <p>mymap value = {{mymap[mymapkey]}}</p>  </div>


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -