AngularJS ngModel directive in select

I am working on an angularjs project and i have a problem with the ngModel not binding within the select.But the same concept is working in another select tag and in the same html page.
Below is the code.

  <select ng-model="selectedFont" 
          ng-options="font.title for font in fonts" 

onFontChange() function is placed in the controller.

Anyone help is highly appreciable…Thanks in advance.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Based on Tony the Pony’s fiddle :

<div ng-app ng-controller="MyCtrl">
    <select ng-model="opt"
            ng-options="font.title for font in fonts"


With a controller:

function MyCtrl($scope) {
    $scope.fonts = [
        {title: "Arial" , text: 'Url for Arial' },
        {title: "Helvetica" , text: 'Url for Helvetica' }
    $scope.change= function(option){

Solution 2

First create data (can be local or from server) in Controller. And initialize the default value, which force the default item selected in HTML form.

// supported languages
$scope.languages = ['ENGLISH', 'SPANISH', 'RUSSIAN', 'HINDI', 'NEPALI'];
// init default language
$scope.language = 'ENGLISH';

Now in your HTML form

<select class="form-control" ng-model="language">
    <option ng-repeat="language in languages">{{language}}</option>

The screenshot is here (note bootstrap CSS is used and not included here).

enter image description here

You can do a test in controller, whether the change is working

$scope.$watch('language', function (newVal, oldVal) {
    console.log(oldVal + " -> " + newVal);




Hope this is helpful. Thanks!

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply