How to Populate the dropdown in angularjs -
i want create 1 dropdown data. here snippet
<!doctype html> <html> <head> <script src="scripts/angular.min.js"></script> <title></title> </head> <body> <div data-ng-app="myapp"></div> <div data-ng-controller="programcontroller"></div> program: <select name="" id="program" data-ng-options="program program in programs"> <option value="">selectprogram</option> </select> <script> var myapp = angular.module("myapp", []); myapp.controller("programcontroller", function ($scope) { $scope.programs = ['.net', 'java', 'angular js,'php','c++']; }); </script> </body> </html>
but empty dropdown. there mistake in snippet?
this tested code , working me.you wrote controller out side data-ng-app="myapp". , please insert single quotation in line '.net', 'java', 'angular js','php','c++' after third item
<div data-ng-app="myapp" data-ng-controller="programcontroller"> program: <select data-ng-model="selecteditem" data-ng-options="program program in programs"> <option value="">selectprogram</option> </select> </div> <script> var app = angular.module('myapp', []); app.controller('programcontroller', function ($scope) { $scope.programs = [ '.net', 'java', 'angular js','php','c++' ]; }); </script>
hope work too.
Comments
Post a Comment