我正在使用Mean Stack创建一个应用程序,我正在使用jquery插件来选择时间(TimePicki)。当我在文本框中键入文本时,它将其作为输入,但是当我通过使用插件选择时间时,ng-model不能在该文本框中工作并返回undefined。以下是代码。
Express API
router.post('/tariff', function(req, res) {
var tariff = new Tariff();
tariff.CabType = req.body.CabType,
tariff.NormalRate = req.body.NormalRate,
tariff.PeakRate = req.body.PeakRate,
tariff.StartPeakHour = req.body.StartPeakHour,
tariff.EndPeakHour = req.body.EndPeakHour,
tariff.Status = req.body.Status
tariff.save(function(err) {
if (err) {
console.log('Error in Saving user: ' + err);
throw err;
} else {
console.log('Tariff Saved');
}
});
});
HTML代码
<input id="starttimepicker" class="form-control" ng-model="Tariff.StartPeakHour" placeholder="Starting Peak Hour" />
<input id="endtimepicker" class="form-control" ng-model="Tariff.EndPeakHour" placeholder="Ending Peak Hour" />
控制器代码
$('#starttimepicker').timepicki();
$('#endtimepicker').timepicki();