I want to implement the following functionality:
Suppose you have 1 input field and 2 drop-down lists. At the input field you can fill in your e-mail address and next to that you can choose what kind of type this e-mail is (Personal, Professional, Other, or nothing).
Now in the third drop-down list you will see a list of e-mails where you can choose from, the e-mail address you prefer.
So what should happen:
1) If there is nothing in the input field the preferred e-mail drop-down list is empty (this is already the case).
2) When there is an e-mail filled in AND a TYPE, the preferred e-mail drop-down list should contain this value: [email protected] (Personal) for example.
3) When there is an e-mail filled in but no TYPE, the preferred e-mail drop-down list should contain this value: [email protected] for example so without the type.
HTML:
<div ng-repeat=email in contactInfo.emails>
<input id=email type=text ng-model=email.email/>
<select id=emailType ng-model=email.emailTypeId ng-options=emailType.id as emailType.name for emailType in emailTypes>
<option value=>Choose...</option>
</select>
</div>
<br/><br/>
<label>Preferred e-mail:</label>
<select style=margin-left: 20px; width: 50%; id=preferred-email ng-model=contactInfo.preferredEmail ng-options=email.email for email in (contactInfo.emails | filter:filterEmail) track by email.id>
<option value=>Choose...</option>
</select>
JAVASCRIPT:
function MyCtrl($scope){
$scope.contactInfo = {};
$scope.emailTypes = [{label:Personal,id:1,name:Personal,rank:2},{label:Professional,id:2,name:Professional,rank:2},{label:Other,id:3,name:Other,rank:4}];
$scope.contactInfo.emails = [{id:1100, emailTypeId:2,email:[email protected]}, {id:1200, emailTypeId:1,email:[email protected]}];
$scope.contactInfo.prefferedEmail = {};
$scope.filterEmail = function(email){
return (email.email);
}
}
JSFIDDLE:
HERE is the fiddle but only the first one is working.
I don't have ant clue so it would be great if someone could help me with this. Thank you for your time.
Sven.