0

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.

2
  • use in controller $scope.dateTime = { timeValue : new Date() } and in model ng-model="dateTime.timeValue" Commented Sep 19, 2017 at 7:13
  • I have posted the answer and documentation link of angular please check it Commented Sep 19, 2017 at 7:21

1 Answer 1

1

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!

Sign up to request clarification or add additional context in comments.

3 Comments

Actually, I still need your help.Doing console.log($scope.dateTime.timeValue); won't show the time I picked, it will just show up empty.
Have you add ng-model dateTime.timeValue
Yeah, ignore me, it's too early in the morning. I've put the $scope.dateTime = { timeValue : '' } inside the function, and of course it'll set the date to nothing. I moved them out of it and it's done. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.