我将用户添加到数据库中,我决定添加一个新字段,即
<div class="input-field col s4">
<select ng-model="register.regData.area" >
<option value="Web">Web Dev</option>
<option value="Android">Android</option>
<option value="Ios">Ios</option>
<option value="Marketing">Marketing</option>
<option value="Desing">UX & UI</option>
</select>
<label>Area</label>
</div>
更清楚,这是有效的
<div class="col s6">
<input value="Male" type="radio" id="male" ng-model = "register.regData.sex" />
<label for="male" data-error="wrong" data-success="right">Male</label>
</div>
但数据库显示:{
"_id" : ObjectId("595ef73540320c1a463a0c0b"),
"area" : null,
"sex" : "male",
"__v" : 0
}
这是控制器:
.controller('regCtrl', function($http, $location, $timeout, User) {
var app = this;
this.regUser = function(regData) {
app.errorMsg = false;
app.loading = true;
User.create(app.regData).then(function(data) {
if (data.data.success) {
app.loading = false;
app.succesMsg = data.data.message + '... redirecting';
$timeout(function(){
$location.path('/');
},1000);
} else {
app.loading = false;
app.errorMsg = data.data.message;
}
})
};
})
我的问题是,如何才能获得所选选项的正确值?