1
我想將小時和分鐘轉換爲秒將發送到API,但我沒有得到轉換秒。我應該向API發送什麼值。小時和分鐘到秒
HTML:
<form ng-submit="vm.handleAddBrief(vm.briefAttractionData)">
<div class="form-group">
<label class="control-label col-md-3">Duration
</label>
<div class="col-md-6">
<div class="input-group input-medium margin-top-10" name="duration">
<input type="text" class="form-control" ng-model="vm.briefAttractionData.hours">
<span class="input-group-addon">
hrs
</span>
<input type="text" class="form-control" ng-model="vm.briefAttractionData.minutes">
<span class="input-group-addon">
mins
</span>
<!--{{seconds | secondsToDateTime | date:'HH:mm:ss'}}-->
</div>
</div>
</form>
控制器:
function addBriefController($scope, $state, $timeout, $location, addBriefService) {
var vm = this;
vm.handleAddBrief = function (data) {
var duration = function(data) {
var hrs = Math.floor(data.hours * 3600);
var min = Math.floor(data.minutes * 60);
var totalSeconds = Math.floor(hrs + min);
}
addBriefService.addBrief(data, function (response) {
if (response.status === 200) {
$state.go('newAttraction.image');
} else {
$state.go('newAttraction.image');
}
});
}
你這是在'data'得到些什麼? – Vineet
在數據中我點擊保存時從html獲取值。 –
'data.hours'和'data.minutes'包含什麼? – alex