Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

set default value in dropdown angular 7

Set validation.min with required as well like below one.

supplierId: ["", [Validators.required, Validators.min(1)]]
supplierId is always greater zero so min(1) works for you.
Comment

Setting the default value in the drop down list in AngularJS

EmployeeStatusChangeRoutingInput: {
    Action: 'value3'
}

ng-options="option.Name as option.Value for option in Data.Actions"
angular.module('myApp', [])
  .controller('myCtrl', ['$scope', function($scope) {
    $scope.Data = {
      Actions: [{
        Value: 'test1',
        Name: 'value1'
      }, {
        Value: 'test2',
        Name: 'value2'
      }, {
        Value: 'test3',
        Name: 'value3'
      }],
      EmployeeStatusChangeRoutingInput: {
        Action: 'value3'
      }
    }

  }])

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
  
  <div class="dropdownIcon">
    <select name="actions" id="actions" ng-options="option.Name as option.Value for option in Data.Actions" ng-focus="ActionsLabel = true" ng-blur="ActionsLabel = false;" ng-model="Data.EmployeeStatusChangeRoutingInput.Action"></select>
  </div>
</div>
Comment

set default value in dynamic dropdown angularjs

$http.post('commandCenter.aspx/allCustomer', {}).then(
                    function onSuccess(response) {
                        $scope.customers = JSON.parse(response.data.d);
                        if ($scope.customers.length === 1) {
                          $scope.relatedTo = $scope.customers[0].CUSTCODE;
                        }
                        console.log($scope.customers); },
                    function onError(response) {
                        console.log('error !!! ');
                    });
Comment

PREVIOUS NEXT
Code Example
Javascript :: web storage api 
Javascript :: add element in array 
Javascript :: npm module 
Javascript :: cypress check if an element is visible 
Javascript :: inner function in javascript 
Javascript :: bonjour 
Javascript :: binance js 
Javascript :: react js photo gallery 
Javascript :: what is prototype in javascript 
Javascript :: react native panresponder on click 
Javascript :: send json in javascript 
Javascript :: multiple images on cloudinary 
Javascript :: foreach await js 
Javascript :: Find a palindrome using Array methods 
Javascript :: set.contains in javascript 
Javascript :: mergesort 
Javascript :: lazy loading by scroll vue 
Javascript :: sequelize change item 
Javascript :: particle js 
Javascript :: example custom theme material ui 
Javascript :: cookie-parser get cookie 
Javascript :: how to assign dynamic value to variable in javascript 
Javascript :: err handling express 
Javascript :: create region in javascript 
Javascript :: raw: true in sequelize 
Javascript :: array count in mongoose query 
Javascript :: javascript algorithm interview questions 
Javascript :: dispatch store 
Javascript :: discord bot not responding to commands 
Javascript :: add to json object javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =