Simple ng-change not working properly in angularjs

angularjs, javascript

Solution

`ng-change` requires `ng-model` as well.

<div ng-controller="MainCtrl">
    <label ng-repeat="question in questions">
        {{question.title}}
        <input type="{{question.type}}" ng-model="question.placeholder" ng-change="change()" />
        <br />
    </label>
</div>

Check out this JSFiddle.

Problem

I might be missing something stupidly as this simple code doesn't work as expected. What is wrong is the `$scope.change` function in the MainCtrl doesn't work (no alert box popped up). In a nutshell, the view is (it's in jade, better to view?) ``` <body ng-app="epfApp"> ... label(ng-repeat="question in questions") | {{ question.title }} input(type="{{question.type}}", ng-change="change()") ``` and in the controller file ``` angular.module('epfApp') .controller('MainCtrl', function ($scope, $window) { $scope.questions = { '1': { 'title': 'The first question is?', 'type': 'text', 'placeholder': 'first question' }, '2': { 'title': 'The second question is?', 'type': 'text', 'placeholder': 'second question' } }; $scope.change = function() { $window.alert('text'); }; }); ``` And the route: ``` $routeProvider .when('/', { templateUrl: 'views/main.html', controller: 'MainCtrl' }); ``` Now what it is doing properly is that it correctly populates the view with the data created (i.e. the questions json). However, What it is not doing properly is the `change()` function bound to the input textbox doesn't work. What am I missing here? This obviously is a very basic job.

Original source