-1

I already got and display the current time using angularjs. What I want to know is how can I pass this value into the dropdown? thanks

     <div class="container-fluid main_content">

    <div class="col-sm-12 col-xs-12 title_box"> 
            <h4 class="subject_title">System Time</h4> 
            <div class="" align="left" >


          <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
              <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script>
    <script type="text/javascript">
     var mymodal = angular.module('mymodal', []);

mymodal.controller('Ctrl2', ['$scope', function ($scope) {
  $scope.format1 = 'M/d/yy  ';
  $scope.format = 'h:mm:ss a ';
   $scope.format2 = 'Z ';

}]);

my whole code is on this plunker file : http://plnkr.co/edit/fnqEG1jfwTWe1MNIXKDz?p=preview

i hope someone can help me

9
  • does this means I still have to write time data into json or xml file? @Anil Panwar Commented Dec 20, 2015 at 8:37
  • does this means I still have to write time data into json or xml file? @AnilPanwar ? Commented Dec 20, 2015 at 8:50
  • why the downvote eh? Commented Jan 13, 2016 at 1:27
  • I don't know who voted it down n why? Commented Jan 13, 2016 at 2:51
  • @AnilPanwar can you help me on how can I show the save as dialog box like this docs.google.com/document/d/… when I click the save button ?here's my plunker plnkr.co/edit/8oDrrIyn0XSduagYtadK?p=preview Commented Jan 13, 2016 at 3:43

1 Answer 1

0

I am not quite sure what you mean, dropdown, I didn't see it in your demo, but I hope this is what you want, you can access the scope property all time, but inside setTimeout, you will have to use $apply, check this http://jimhoskins.com/2012/12/17/angularjs-and-apply.html :

http://plnkr.co/edit/oTGmpIPVc4r8JHrQ8cj9?p=preview

  function updateTime() {
    var dt = dateFilter(new Date(), format);
    //element.text(dt);
    scope.$apply(function() {

      scope.dropdownValue = dt;
    });
  }

In the div, access the dropdownValue:

<div class="item_contentbox"> 
        <span my-current-time="format">
          {{dropdownValue}}
      </span>
</div>
Sign up to request clarification or add additional context in comments.

1 Comment

Thank You @Tom but this code assigns the current time value under the Timezone field. What I want is to make three separate dropdown fields then assign to those the value of the current time; the hour, the minutes and the seconds respectively. The value of the dropdown is also clickable and changeable for the user to edit the time he wants. Thank you

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.