2017-09-19 42 views
0

我有這一塊的HTML:

 <div class="item item-icon-left" ion-datetime-picker="" time="" ng-model="timeValue"> 
     <i class="icon ion-ios-clock positive"></i> 
     <p><strong">{{timeValue | date:'HH:mm'}}</strong></p>   
    </div> 

而且在我的控制器我有這樣的功能,將火的時候,一個切換被激活:

$scope.funCheck = function(check) {  
     console.log($scope.timeValue);   
    }; 

我用這個:https://github.com/katemihalikova/ion-datetime-picker挑選一個時間並設置它。

它工作正常,但選擇時間,但功能我geting未定義,我不知道爲什麼。 我想要選擇時間,並使用$ Scope在我的控制器中執行一些操作。

+0

使用{ TIMEVALUE:新的Date() }和模型NG-模型=「dateTime.timeValue」 –

+0

我已經發布的角答案和文檔的鏈接,請檢查 –

回答

1

您需要使用「點符號」。由於繼承,簡單的值不會進行雙向綁定。

請使用下面的代碼爲雙向數據與離子

使用控制器

$scope.dateTime = { timeValue : '' } 

,並在模型ng-model="dateTime.timeValue"

閱讀從herehere更多細節結合。

希望這個幫助!在控制器$ scope.dateTime =

+0

其實,我仍然需要你的幫助。做console.log($ scope.dateTime.timeValue);不會顯示我選擇的時間,它只會顯示空白。 – xxxxxxxxxxxxx

+0

你有沒有加ng模型dateTime.timeValue –

+0

是的,不理我,現在太早了。我已經把$ scope.dateTime = {timeValue:''}放在了函數裏面,當然它會把日期設置爲空。我將它們移出它並完成。謝謝。 – xxxxxxxxxxxxx