Angular Ng-options With Preselected Value By Object Id May 24, 2024 Post a Comment Is there a way the following select can have a pre-selected club ? Solution 1: in the controller set the ng-model of the select to the value of the option you want selected. Something like : $scope.c.pilot.clubIdx = 2 or $scope.c.pilot.clubIdx = $scope.c.clubs[1].idxSolution 2: <select ng-model="c.pilot.clubIdx" ng-options="club.idx as club.name for club in c.clubs track by club.idx" ng-selected="(club.idx == 2)?true:false"> Copyadd ng-selected like so. It should be preselectedSolution 3: using underscore/lodash use the following lines in controller:var club =_.where(c.clubs, {name:"club2"}); $scope.c.pilot.clubIdx = club.idx; CopySolution 4: removing the track by clause solves the problem. i dont fully understand why, but who knows. angular doc for ngOptions Share Post a Comment for "Angular Ng-options With Preselected Value By Object Id" Top Question Give This Function An Id We are making a advert div, and we have this function on mo… Getrowheight() Not Working With Rowmodeltype = 'infinite' With Latest Ag-grid Version I see this Note on ag-grid site: Changing the row height i… How To Loop Through Items In A Js Object? how can I loop through these items? var userCache = {}; use… Google Maps Api V3 Marker. Google Is Undefined I've a website with the google maps api which is loaded… Should I Manipulate Dom Directly Or Using React State/props? This is the situation: This component renders many data as … Passing Text_field Value To Will_paginate As Parameter In Rails I have a controller for Books, in index action I am using w… Difference Between For Loop And For-in Loop In Javascript I found that there is a difference between for loop and for… Angular 7 - Add Drag And Drop Behaviour To Dynamically Created Components This is in continuation of the previous question I asked on… Load Different Css Stylesheet With Javascript I need to use javascript to load a different stylesheet bas… Set The Custom Properties In Joining Model Using Loopbacks Hasmanythrough I am trying to set up a many to many relationship in LoopBa… Recent Post Loading... December 2024 (1) November 2024 (39) October 2024 (62) September 2024 (19) August 2024 (375) July 2024 (340) June 2024 (708) May 2024 (1300) April 2024 (812) March 2024 (1586) February 2024 (1733) January 2024 (1387) December 2023 (1412) November 2023 (403) October 2023 (561) September 2023 (102) Widget HTML #3 Menu Halaman Statis Beranda © 2022 - especialidadeseivconstruccion