I am having a user fill out a contact form which includes a dropdown to select what county they are located in.
I am currently using ng-repeat
to create 50+ options.
HTML:
<md-select name="county" ng-model="form.county">
<md-option ng-repeat="county in counties" value="{{county.abbrev}}">{{county.abbrev}}</md-option>
</md-select>
JS:
.controller('slothController', function($scope) {
$scope.counties = ('Not in California,Alameda,Alpine,Amador,Butte,Calaveras,Colusa,Contra Costa,Del Norte,El Dorado,Fresno,Glenn,Humboldt,Imperial,Inyo,Kern,Kings,Lake,Lassen,Los Angeles,Madera,Marin,Mariposa,Mendocino,Merced,Modoc,Mono,Monterey,Napa,Nevada,Orange,Placer,Plumas,Riverside,Sacramento,San Benito,San Bernardino,San Diego,San Francisco,San Joaquin,San Luis Obispo,San Mateo,Santa Barbara,Santa Clara,Santa Cruz,Shasta,Sierra,Siskiyou,Solano,Sonoma,Stanislaus,Sutter,Tehama,Trinity,Tulare,Tuolumne,Ventura,Yolo,Yuba').split(',').map(function(county) {
return {abbrev: county};
})
This works perfectly on the users side, but once the user submits the form (I am also serializing it to JSON), and let's say they selected Santa Clara
as their county.
I would receive an email that has ? string:Santa Clara ?
as the form value for the county.
I want to get Santa Clara
without the ? string: ?
in my email.
I was looking at this thread earlier, but I couldn't find a good solution to my problem because ng-options
does not work with md-select
.
I would really appreciate it if someone can help me solve this problem, I have spend the past 8 hours trying to solve it.