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 :: How to hide div based on select the dropdown in angular js 
Javascript :: when selecting second dropdown ng-model object return null 
Javascript :: How to return $http.post() object with factory function 
Javascript :: I am getting an error "createSpyObj requires a non-empty array" with running unit tests, which were executed perfectly before 
Javascript :: How to pass React Native Component as a JSON object 
Javascript :: Using animateCamera in functional components in react native 
Javascript :: how to edit data retrieval using jsp 
Javascript :: wrapping a span tag with an a tag with a href target same as the text of the span 
Javascript :: javascript array add method 
Javascript :: settimeout and create directory nodejs 
Javascript :: how to build a nested, dynamic JSON in Go 
Javascript :: Node.js with Express: Importing client-side javascript using script tags in Jade views 
Javascript :: Javascript if time is between 7pm and 7am do this? Javascript If Statement Time Action 
Javascript :: filter number from string in javascript 
Javascript :: javascript loop through collection of objects 
Javascript :: word array to string cryptojs 
Javascript :: Creating A Promise With JSON 
Javascript :: convert json date to java date 
Javascript :: In Self Invoking Functions, the This Below Console.Logs The Created Object 
Javascript :: $faker randomElements 
Javascript :: Set Up Model In MongoDB 
Javascript :: continuously update last updated time react js 
Javascript :: Recursion In A Class Function 
Javascript :: how to find default or the first server discord.js 
Javascript :: useState increase Likes 
Javascript :: required field in javascript dynamically 
Javascript :: how to close bootstrap modal after save 
Javascript :: screen orientation and width&height 
Javascript :: convert c# code to javascript 
Javascript :: javascript invert binary tree 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =