Thursday, 15 December 2016

Example of listbox in angularjs


View Code :






<link href="~/Content/bootstrap.css" rel="stylesheet" />
<script src="~/Scripts/angular.js"></script>
<div class="container" ng-app="app" ng-controller="ctrl">
    <form class="form-horizontal"><br />
        <select ng-model="EMP.NAME" multiple class="form-control">
            <option value="1">A</option>
            <option value="2">B</option>
            <option value="3">C</option>
            <option value="4">D</option>
            <option value="5">E</option>
            <option value="6">F</option>
        </select><br /><br />
        <input type="button" value="Press Me" class="btn btn-primary"  ng-click="shwo()"/>
    </form>
</div>
<script type="text/javascript">
    angular.module("app", [])
    .controller("ctrl", function ($scope) {
        $scope.EMP = new emp();
        $scope.shwo = function ()
        {
         
            for (var i = 0; i < $scope.EMP.NAME.length; i++)
                alert($scope.EMP.NAME[i]);
        }
    });
    function emp()
    {
        return {
            NAME:[]
        }
    }
</script>

No comments:

Post a Comment