如何将按钮上的值绑定到我的 ng-model?

How do I bind the value on the button to my ng-model?

我正在尝试将按钮上的值绑定到我的 ng-model,但它似乎不起作用。有人对我应该做什么有什么建议吗?

我正在使用来自 https://github.com/rajeshwarpatlolla/ionic-datepicker

的日期选择器
<div class="col">
  <label class="item item-input small">
   Start Date: <br> 

    <ionic-datepicker input-obj="datepickerObject">        
      <input type="button" ng-model="vm.newObject.startDate" value="
        {{datepickerObject.inputDate|date:'dd - MMM - yy'}}"> 
    </ionic-datepicker>

   </label>
</div> 

button 中删除 ng-model,您可以像这样修改 datepickerObject 对象:

$scope.datepickerObject = {
    // ... Other keys & values
    callback: function(value) {
        $scope.newObject.startDate = value;
        // or use the "vm" variable as you are using (not sure how you are using the scope)
        // vm.newObject.startDate = value; 
    }
};

根据您提到的文档 link:

r) callback(Mandatory) : This the callback function, which will get the selected date in to the controller. You can define this function as follows.

我们可以使用带有 {{}} 的按钮元素来显示返回的数据

<ionic-datepicker input-obj="datepickerObject"> 

    <button type="button">{{datepickerObject.inputDate|date:'dd - MMM - yy'}} 
</button> 

</ionic-datepicker>