Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

angularjs How to pass option value and label created with ng-repeat triggered by ng-change

angular.module('myApp', [])
  .controller('myCtrl', ['$scope', function($scope) {
    $scope.diskSizes = [{
        "label": "100GB",
        "value": 100
      },
      {
        "label": "250GB",
        "value": 250
      },
      {
        "label": "500GB",
        "value": 500
      },
      {
        "label": "1TB",
        "value": 1000
      },
      {
        "label": "1.5TB",
        "value": 1500
      }
    ]

    $scope.saveData = function() {
      let val = $scope.disk_size;
      let lab = $scope.diskSizes.filter(f => f.value == val)[0].label;
      console.log(lab, val)
    }
  }]);
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">

  <select ng-model="disk_size" ng-change="saveData()">
    <option ng-repeat="item in diskSizes" value={{item.value}}>{{item.label}}</option>
  </select>


</div>
Comment

PREVIOUS NEXT
Code Example
Javascript :: ! function in javascript 
Javascript :: angularjs promise .then() to run sequentially inside a for loop 
Javascript :: AngularJS SPA edit button function 
Javascript :: directive with ng-if not rendering in Angular.js 
Javascript :: Algolia backend search with Algolia Search Helper library for Angular.js 
Javascript :: Easy Angular way to detect if element is in viewport on scroll 
Javascript :: Angular.js : recursive call to an $mdDialog controller 
Javascript :: Angular js set default tab with ng-repeat in array object 
Javascript :: React Native, <TextInput onChange{(text) = setState(text)} is returning an object instead of a string. Eventhough the default value is a String. Why 
Javascript :: How to add the items from a array of JSON objects to an array in Reducer 
Javascript :: react js graph with more than one y axis 
Javascript :: javascript array add method 
Javascript :: splunk : json spath extract 
Javascript :: Get value by key from json array 
Javascript :: vscode search shortcut 
Javascript :: morgan 
Javascript :: Simple Mustache.js 
Javascript :: how to send token in get request vue js 
Javascript :: phaser reverse matrix columns 
Javascript :: vimscript replace function 
Javascript :: Javascript Encapsulation Inheritance Polymorphism Composition 
Javascript :: Second Simplest Promise Example 
Javascript :: how to display unicode in javascript 
Javascript :: Error: Invalid route module file 
Javascript :: Update A Value In ExpressJS/MongoDB 
Javascript :: https://javascript.plainenglish.io/javascript-algorithms-valid-parentheses-leetcode-71c5b2f61077 
Javascript :: How to Loop Through an Array with a for…of Loop in JavaScript 
Javascript :: Backbone Set Model In View 
Javascript :: Backbone View Notes 
Javascript :: 2d array js 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =