0

I want to get a drop down lsit of various operating systems for the user to select. This is my code so far

<form id="main">
    <table>
        <tr>
            <td class="display_bold"><label for="name">VM Name:</label></td>
        </tr>
        <tr>
            <td class="display"><input type="text" ng-model="virMachine.vmName" size="40"></td>
        </tr>
        <tr>
            <td class="display_bold" ><label  for="name">OS Type:</label></td>
        </tr>
        <tr>
            <td class="display"><input type="text" ng-model="virMachine.osVersion" size="40"></td>
        </tr>
    </table>

This is the OS list i want to create a drop-down menu out of.

$scope.operatingsystems = ["Ubuntu-16", "Centos 7", "Wimdows"];

How do I do it? I know I might have change the input type from text to something else but not sure what.

2
  • 1
    you want to show inside the table? Commented Jun 15, 2017 at 18:15
  • Yes please. This part <td class="display_bold" ><label for="name">OS Type:</label></td> Commented Jun 15, 2017 at 18:23

2 Answers 2

2

Just you can do this,

<select ng-model="osType">
   <option ng-repeat="os in operatingsystems">{{os }}</option>
</select>

DEMO

angular.module('myApp',[]).controller('studentController', function($scope){
$scope.operatingsystems = ["Ubuntu-16", "Centos 7", "Wimdows"]; 
 });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>

<body>
    <div ng-app="myApp" ng-controller="studentController">
        <table>
            <tr>
                <td class="display_bold"><label for="name">VM Name:</label></td>
            </tr>
            <tr>
                <td class="display"><input type="text" ng-model="virMachine.vmName" size="40"></td>
            </tr>
            <tr>
                <td class="display_bold"><label for="name">OS Type:</label></td>
            </tr>
            <tr>
                <td class="display"><select ng-model="osType">
                        <option ng-repeat="os in operatingsystems">{{os }}</option>
</select></td>
            </tr>
        </table>
    </div>
</body>

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you so much!!
just change ng-model
i figured it out... that's why i deleted the comment. Thanks again :)
0

A dropdown in Angular.js could look something like this:

<select ng-model="osType">
    <option value=" ">Choose OS</option>
    <option ng-repeat="o in operatingsystems">{{o}}</option>
</select>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.