Friday, 15 March 2013

javascript - AngularJS select dropdown - Select default option -



javascript - AngularJS select dropdown - Select default option -

i have angluarjs dropdown, each alternative "onchange" take navigate page. here code:

<select class="qtdropdown" ng-model="suggested" ng-change="changeoption()" ng-options="option.name alternative in suggested">

js.

$scope.suggested = strategyservice.getpredefinedstrategies(); $scope.suggested = $scope.suggested[0]; $scope.changeoption = function () { var selectedstrategy = $scope.suggested; var querystring = selectedstrategy.name.split(' ').join(''); window.location.href(baseurl+querystring); };

the problem here when click on default selection $scope.suggested[0]; not navigating user. can suggest doing error please ?

it's normal when select $scope.suggested[0] there not alter has default.

one way prevent adding blank alternative

<select class="qtdropdown" ng-model="suggested" ng-change="changeoption()" ng-options="option.name alternative in suggested"> <option value=""> - take 1 of next - </option> </select>

that way, when select $scope.suggested[0], there alter trigerred.

javascript angularjs

No comments:

Post a Comment