ng-if on a portal widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2019 10:37 AM
On a portal widget we have a 'work email address' field and an 'alternate email address' field. What I am trying to do is if 'work email address' field is blank then 'alternate email address' should be mandatory. How do I do this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2019 11:15 AM
If this is a custom widget you'll probably need to post your widget code to get a good answer.
If this is for a widget through the catalog or something like that you can just use the existing form widget and a ui policy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2019 11:34 AM
<!--Work Email-->
<div class="form-group col-md-6"
ng-if="c.registration_mcemployee === 'Yes'"
ng-class="{ 'has-error' : mcexperiencedr.registration_work_email.$invalid && c.submitted }">
<label class="control-label" for="registration_work_email">Work E-Mail Address</label>
<input id="registration_work_email" name="registration_work_email" type="text" class="form-control input-md" placeholder="{{data.emp.email}}" readonly
ng-model="c.registration_work_email"
>
</div>
<!--Alternate E-Mail Address-->
<div class="form-group col-md-6"
ng-if="c.registration_mcemployee === 'Yes'"
ng-class="{ 'has-error' : mcexperiencedr.registration_personal_email.$invalid && c.submitted }"
>
<label class="control-label" for="registration_personal_email">Alternate E-Mail Address</label>
<input id="registration.email" name="registration_personal_email" type="text" class="form-control input-md"
ng-model="c.registration_personal_email"
ng-required="!c.registration_work_email"
>
</div>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2019 11:42 AM
If you're checking to see if it's empty or not, you could try
ng-required="c.registration_work_email == ''"
instead of:
ng-required="!c.registration_work_email"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2019 12:56 PM
that didn't work