i have written first directive in angular, dropdown, here template :
<select class='form-control' ng-model='vm.scope.fixturetobeupdated.awayteam' ng-options='awayteam.teamname awayteam in vm.scope.awayteams track awayteam.teamid' required> <option style='display: none' value=''>{{'select' | translate }}</option> </select>
here defined in controller :
function awayteamsdropdown() { return { restrict: "e", scope: true, controller: "fixturescontroller", templateurl: "/views/awayteamsdropdown.html" }; }
and here form used in :
<form novalidate id="addupdatefixture" name="addupdatefixture" ng-submit="vm.addupdatefixture()"> <!--addfixture or updatefixture--> <div class="form-group"> <input type="hidden" ng-model="vm.scope.fixturetobeupdated.fixtureid"/> </div> <div class="form-group"> <label for="tournament">{{ 'tournament' | translate }}</label> <tournaments-dropdown></tournaments-dropdown> </div> <div class="form-group"> <label for="week">{{ 'week' | translate }}</label> <weeks-dropdown></weeks-dropdown> </div> <div class="form-group"> <label for="awayteamname">{{ 'away_team' | translate }}</label> <awayteams-dropdown></awayteams-dropdown> </div> <div class="form-group"> <label for="awayteamscore">{{ 'points' | translate }}</label> <input id="awayteamscore" type="text" class="form-control" name="awayteamscore" ng-model="vm.scope.fixturetobeupdated.awayteamscore" ng-min="0" ng-max="77" /> <span ng-show="addupdatefixture.awayteamscore.$dirty && addupdatefixture.awayteamscore.$error.min" class="text-warning">{{ 'score_min' | translate }}</span> <span ng-show="addupdatefixture.awayteamscore.$dirty && addupdatefixture.awayteamscore.$error.max" class="text-warning">{{ 'score_max' | translate }}</span> </div> <div class="form-group"> <button type="submit" ng-disabled="addupdatefixture.$invalid" class="button bg-darkblue bg-active-darkblue fg-white">{{ 'save' | translate }}</button> </div> </form>
but in button in form ng-disabled set false if item not selected dropdown. how make ng-disabled set true if nothing selected in dropdown?
give try this
<div class="form-group"> <button type="submit" ng-disabled="vm.scope.fixturetobeupdated.awayteam === undefined" class="button bg-darkblue bg-active-darkblue fg-white">{{ 'save' | translate }}</button> </div>
or
ng-disabled="!vm.scope.fixturetobeupdated.awayteam"
Comments
Post a Comment