我在后端有三个字段: -
productCode: {type : String, required: true, index: true},
value: String,
productInternal: {type : String, required: true, index: true, unique: true}
我想将productInternal字段值设置为等于其他两个的连接:
valueproductCode
。
“价值”和“产品代码”由用户提供: -
<select ng-model="a.productCode" name="" ng-options="pc for pc in productCodes">
<option value="">Please Select</option>
</select>
<select ng-model="a.value" name="" ng-options="v for v in value">
<option value=""></option>
</select>
第三个字段productInternal
是隐藏字段,不向用户显示。
在调用add segment API时,我必须将productInternal字段设置为值和productCode的串联,
ApiServices.addProduct(scope.a).then(function (response) {
console.log('added');
scope.notify('success', response.data);
}
任何想法如何做到这一点?
答案 0 :(得分:0)
尝试
scope.a.productInternal=scope.a.value+scope.a.productCode;
ApiServices.addProduct(scope.a).then(function (response) { console.log('added'); scope.notify('success', response.data); }
答案 1 :(得分:0)
// "+ ''": optional; it's just to enforce concatenation instead of summing, just in case two fields are numeric.
$scope.a.productInternal = $scope.a.value + '' + $scope.a.productCode;
ApiServices.addProduct($scope.a).then(function (response) {
console.log('added');
scope.notify('success', response.data);
}