我有四个按钮。以下是他们的HTML,
<label>Severity *</label>
<button class="btn btn-default btn-lg" ng-click="sModal()" name="s" ng-model="cpform.severity">{{cpform.severity}}</button>
<label>Occurence *</label>
<button class="btn btn-default btn-lg" ng-click="OModal()" name="o" ng-model="cpform.occurence">{{cpform.occurence}}</button>
<label>Detection *</label>
<button class="btn btn-default btn-lg" ng-click="siverifydetectionModal()" name="detection" ng-model="cpform.detection">{{cpform.detection}}</button>
<label>RPN</label>
<button class="btn btn-default btn-lg" ng-model="cpform.risk_score">{{cpform.severity*cpform.occurence*cpform.detection}}</button>
所有这4个按钮都显示在模态中。前三个按钮的值来自不同的模态。在这里,我在RPN的最后一个按钮中显示了Product值。当我试图保存该值时,我能够保存除最后一个按钮值之外的前三个按钮的值。
以下是我在控制器部分的代码:
$scope.cpform = {
summary: r_header.summary,
severity:r_header.severity,
occurence:r_header.occurence,
detection:r_header.detection,
risk_score: r_header.risk_score,
nocpz: nocpz_checked,
route: r_header.route,
layers: r_header.layers,
comments: r_header.comments,
risks: risk_id_list,
};
}
$scope.updateReview = function (cpform, formname) {
$scope.uprev_submit_disabled = true;
var updated_field_list = [];
if (r_header.revSeverity[0] != null) {
angular.forEach($scope.cpform, function(value, key) {
//if(key[0] == '$') return;
console.log("Chck", value, key);
if (!formname[key].$pristine) {
updated_field_list.push(key);
}
console.log("CPZ", key, formname[key].$pristine)
});
我想通过控制器中提到的risk_score变量传递我在RPN按钮中获得的产品值。我将$ scope.cpform传递给视图,并分别传递给模型以保存它。请告诉我如何将我在RPN按钮中获得的Product值保存到db。我想在risk_score变量中传递并保存值。