2 回答

TA貢獻1827條經(jīng)驗 獲得超4個贊
嘗試將其放在類似的函數(shù)上
$scope.setDraft = function(isDraft) {
$scope.isDraft = isDraft;
//try console.log() to see if the values are correct
//but if its keeps return false try adding this $scope.$apply();
}
在你的html中會是這樣的
<div>
<input type="submit" ng-click="setDraft(false)" value="Add new" />
</div>
<div>
<input type="submit" ng-click="setDraft(true)" value="Save as draft" />
</div>
或者您可以使用 @Eric 建議而不是使用 ng-submit,只需創(chuàng)建新函數(shù)并在 ng-click 上使用,如下所示
$scope.submitNew = function(isDraft) {
$http({
method: 'POST',
url: '/app/submit',
data: {
text: $scope.myForm.text,
isDraft: isDraft,
}
})
};
在html中會是這樣的
<form>
<div>
Text:
<input type="text" ng-model="myForm.text" />
</div>
<div>
<input type="button" ng-click="submitNew(false)" name="correct" value="Add new" />
</div>
<div>
<input type="button" ng-click="submitNew(true)" name="draft" value="Save as draft" />
</div>
</div>
</form>
- 2 回答
- 0 關注
- 222 瀏覽
添加回答
舉報