select by default value for dropdown not working by using 'track by' in angualrjs

前端 未结 2 550
温柔的废话
温柔的废话 2021-01-25 20:57

I am using track by to avoid strange values ::string that are appending to value but when i select by default dropdown , dropdown is not g

2条回答
  •  半阙折子戏
    2021-01-25 21:39

    (function(angular) {
      'use strict';
    angular.module('defaultValueSelect', [])
      .controller('ExampleController', ['$scope', function($scope) {
        $scope.data = {
         availableOptions: [
           {id: '1', name: 'Option A'},
           {id: '2', name: 'Option B'},
           {id: '3', name: 'Option C'}
         ],
         selectedOption: '2' //This sets the default value of the select in the ui
         };
     }]);
    })(window.angular);
    
    
    
      
      Example - example-select-with-default-values-production
      
      
    
    
      

    option = {{data.selectedOption}}

    Working snippet of your demo

    Please change your

提交回复
热议问题