Currently, I have a dropdown menu that allows users to select a report for generation. When a user picks a report from the dropdown, it generates and downloads the report for mobile viewing. By utilizing ng-change, the system only detects when a user wants to generate different reports. However, I would like the system to allow users to select the same item from the dropdown multiple times and download the report on each selection.
The code structure is as follows:
Markup:
<div>
<select ng-model="currentlySelected"
ng-options="opt as opt.label for opt in options"
ng-change="logResult()">
</select>
The selected value is {{ currentlySelected.value }}.
</div>
Javascript:
angular.module('demoApp', []).controller('DemoController', function($scope) {
$scope.options = [
{ label: 'one', value: 1 },
{ label: 'two', value: 2 }
];
$scope.currentlySelected = $scope.options[1];
$scope.logResult = function() {
console.log($scope.currentlySelected);
}
});
Fiddle: http://jsfiddle.net/KyleMuir/cf59ypyw/
My expectation is to be able to select "two" twice and see the result logged in the console twice. Is there a way to achieve this with the current directive, or should I explore other options?