How to customize this code to make it execute some instructions on each change of selection. And which takes as default value this.annee
.
html
<span class="form-group" ng-controller="FiltreFicheController as ffCtl">
<select name="annee" ng-model="annee">
<option value="2014" ng-selected="ffCtrl.isSelected(2014)" ng-change="ffCtrl.selectElt(2014)">2014</option>
<option value="2000" ng-selected="ffCtrl.isSelected(2000)" ng-change="ffCtrl.selectElt(2000)">2000</option>
</select>
</span>
js
app.controller('FiltreFicheController', function($scope, $location){
var link = document.URL;
var type_param = (!location.search.indexOf('?', link)?location.search.split('type=')[1].split('&')[0]:'undefined');
var annee_param = (!location.search.indexOf('?', link)?location.search.split('annee=')[1]:'undefined');
this.type = (type_param!=='undefined'?parseInt(type_param):1);
this.annee = (annee_param!=='undefined'?parseInt(annee_param):2014);
this.isSelected = function(annee){
return this.select === annee;
}
this.selectElt = function(numElt){
this.annee = numElt;
window.location.href = link.substring(link.indexOf('/'),link.lastIndexOf('/')) + '/fiche?type=' + this.type + '&annee=' + numElt;
}
});
Thanks in advance!