I am using angularjs, I have a directive which shows list of questions. I intend to do some logic when selectedQuestion changes. So, I used ng-change.
This is my directive:
restrict: 'EA',
scope: {
selectedQuestion: '=?',
questionsList: '='
},
link: function (scope) {
scope.change = function () {
if (scope.selectedQuestion) {
//do something
}
};
}
This is the html template for my directive:
<select ng-model="selectedQuestion"
ng-options="avail.question for avail in questionsList track by avail.id" ng-change="change()"
</select>
{{selectedQuestion}}
When I change the question in the UI list, the {{selectedQuestion}} changes to show the json of the question selected. However the scope.selectedQuestion in scope.change function is always the same as initialized (not changing).
What is causing this issue?