HOW TO BIND (SET) DROPDOWNLIST VALUE AND TEXT USING NG-OPTIONS OR NG-REPEAT ANGULARJS

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
 716  View(s)
Ratings:
Rate this:
I want to bind Dropdownlist Value and Text using Angularjs . How to do this.
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: how to Bind (Set) Dropdownlist Value and Text using ng-Options or ng-Repeat Angularjs

    
    
    

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AngularList.aspx.cs" Inherits="Forumasp.AngularList" %>

    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml" ng-app="UserApp">

    <head runat="server">

        <title></title>

        <script src="Scripts/jquery-2.1.4.js"></script>

        <script src="Scripts/angular.min.js"></script>

        <script type="text/javascript">

            var app = angular.module('UserApp', []);

            app.controller("CntrUser", ['$scope', function ($scope) {

                $scope.items = [

                        { UserID: "PA011", UserName: "Pawan Shukla" },

                        { UserID: "SU210", UserName: "Suresh Kumar” },

      { UserID: "MA320", UserName: "Manoj Kumar" }

                ];

            }]);

        </script>

    </head>

    <body>

        <div ng-controller="CntrUser"> 

    <br />

            <label>Select User:

       <select>

    <option data-ng-repeat="t in items" value="{{t.UserID}}">{{t.UserName}}</option>

    </select>

      </label><br/>

        </div>

    </body>

    </html>

     

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!