I have a form in angular js and a button (angular material md-button) outside of the form. I want to disable the button when the form is invalid but access the form from outside is seems impossible :(
note: I try form attribute for my button and ng-disabled="secFoundedFormId.$invalid" but this expression outside of the form seems unsuspected!
Any help is appreciated
Here is my summarised code :
<form flex="100" ng-if="secretaryFound" name="secFoundedForm" id="secFoundedFormId">
<!-- my required input -->
<div class="disabledInputMargin" flex="95" flex-xs="100" layout="row"
layout-align="start start">
<md-icon class="zeroMargin" style="color:{{DashboardParams.iconColor2}};">
person
</md-icon>
<md-select class="zeroMargin" flex="100" flex-xs="100" required
ng-model="form.workplaceLableId"
name="mahaelekar"
placeholder="{{'WORKPLACE' | translate}}">
<md-option ng-repeat="workplace in workplaceLableList"
value="{{workplace.id}}">
{{workplace.addressLable}}
</md-option>
</md-select>
</div>
</form>
****{{secFoundedForm.$invalid}}*** <!-- this is not show enything -->
<div style="padding: 0">
<div flex="100"
layout="row"
layout-xs="column"
layout-align="end stretch">
<!-- my button is below -->
<md-button ng-if="secretaryFound" ng-click="inviteSecretary();"
name="secFoundedFormId"
form="secFoundedFormId"
style="background-color:{{DashboardParams.iconColor2}};color: white"
ng-disabled="secFoundedForm.mahaelekar.$invalid"
flex="20" flex-xs="100">
{{'INVITE' | translate}}
</md-button>
<md-button ng-click="backToSecretary();" style="background-color: #9d9d9d;color: white"
flex="20" flex-xs="100">
{{'BACK' | translate}}
</md-button>
</div>
</div>
</div>