Navigation

Thursday 23 August 2018

Set Dropdown Default Value Using Angularjs

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
  <script>
      angular.module("myapp", [])
        .controller("MyController", function ($scope) { 
            $scope.JobPositionId = "1";
            $scope.JobPositions = [{
                id: "1",
                name: "Event Staff"
            }, {
                id: "2",
                name: "Event Manager"
            }, {
                id: "3",
                name: "Security Guard"
            }, {
                id: "4",
                name: "Ticket Taker"
            }];
        });    
  </script>
</head>
<body ng-app="myapp">
  <div ng-controller="MyController">
    <p>
      <h2>Set default value in dropdown list in AngularJs</h2>
    </p>
    <div>
      JobPosition Name :
      <select ng-model="JobPositionId" ng-options="JP.id as JP.name for JP in JobPositions"></select>
    </div>
    <div>
      JobPosition-Id : {{JobPositionId}}
    </div>
  </div>
</body>
</html>


1 comment:

  1. Casino Slot Machines For Sale in NV | DrMCD
    Jun 12, 2020 · 5 posts · 7 authorsWith our huge collection 충주 출장샵 of casino 계룡 출장안마 slot machines, our Las Vegas Casino 통영 출장마사지 & Hotel has a new look to your life, 광주 출장안마 from 강원도 출장샵 thrilling reel machines to

    ReplyDelete