My goal is to retrieve a date value. However, I encounter an error message saying 'Cannot read property 'NTLI' of undefined' whenever the checkbox is unchecked and the date picker is invisible. Strangely enough, everything works fine when the checkbox is checked and the date picker is visible.
<md-checkbox ng-model="user.NTLI" layout="row" ng-disabled="userForm.$invalid">
NTLI
</md-checkbox>
<div ng-show="user.NTLI">
<fieldset class="standard">
<legend>NTLI</legend>
<md-input-container>
<label>Effective date</label>
<md-datepicker ng-model="user.effectDateNTLI"></md-datepicker>
</md-input-container>
</fieldset>
</div>
var effectDate = '';
if ($scope.user.NTLI != undefined)
{
effectDate = $scope.user.effectDateNTLI
}