我有这个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来选择时间并设置它。
它可以很好地选择时间,但是,我正在设定未定义的功能,我不知道为什么。 我希望得到我选择的时间,并使用$ Scope在我的控制器中做一些事情。
I have this piece of 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>And in my controller I have this function that will fire when a toggle is activated:
$scope.funCheck = function(check) { console.log($scope.timeValue); };And I use this: https://github.com/katemihalikova/ion-datetime-picker to pick a time and set it.
It works fine to pick the time, however, in the function I'm geting undefined and I dont know why. I want to get the time I picked and do some stuff in my controller with the $Scope.
最满意答案
你需要使用“点符号”。 由于继承,简单值不会进行双向绑定。
请使用以下代码进行与离子的双向数据绑定
在控制器中使用
$scope.dateTime = { timeValue : '' }在模型ng-model="dateTime.timeValue"
从这里和这里了解更多详情。
希望这很有帮助!
You need to be using "dot notation". Because of inheritance, simple values will not do two way binding.
Please use the following code for two way data binding with ionic
use in controller
$scope.dateTime = { timeValue : '' }and in model ng-model="dateTime.timeValue"
Read more details from here and here.
Hope this well help!
更多推荐
发布评论