I've searched Google but can't find the answer...
I have an md-select that looks like this:
<md-input-container class="md-block" flex-gt-sm>
<label>Type</label>
<md-select ng-model="f.type" placeholder="Type" select-clear>
<md-option ng-repeat="f in ctrl.type" value="{{f}}">{{f}}</md-option>
</md-select>
</md-input-container>
ctrl.type looks like this in my controller:
this.type = ["type1","type2"];
and I am also sending the md-select value to an object array like this:
var data = {
kind: $scope.f.type,
};
and then I am doing an http.post that is sending the data object to an api.
Now here is my question. I would like it that when the md-select is empty, and the users sends the data object that instead of getting the error Cannot read property 'type' of undefined that simply the data is sent but it has a value of null instead of undefined, and then when the md-select is populated it simply sends the value to the api. How would I do that? Would I have to do form validation? Is there a simple way of doing this because I have about 10 of the md-selects that I have to send.
Thank you.