【发布时间】:2016-09-07 22:58:16
【问题描述】:
这是我之前使用的代码...
<div class="date_menu" ng-repeat="singledate in dates">
<p>
{{singledate}}
<input type="radio" name="filterDateChosen2" ng-model="$parent.radioResult" ng-value="singledate">
</p>
</div></div>
这会以单选按钮的形式显示日期列表。这将所选日期保存在 $parent.radioResult 中,然后我可以使用...访问它。
<button ng-click="getVar(radioResult)"...
但现在,我想改用 jQuery datepicker...
myApp.directive('calendar', function () {
return function(scope, element, attrs) {
element.datepicker({
inline: true,
dateFormat: 'dd-mm-yy',
onSelect: function(dateText) {
var modelPath = $(this).attr('ng-model');
var val = $(this).attr('ng-value');
putObject(modelPath, val, scope, dateText);
scope.$apply();
}
});
}
});
这可行,如果我选择一个日期,输入框会显示它...
<input calendar ng-model="$parent.radioResult" />
但问题是,当我使用...
<button ng-click="getVar(radioResult)"...
它没有得到价值,我不知道为什么?这是什么原因?
【问题讨论】:
标签: javascript jquery angularjs datepicker