Controller:

$scope.locTime= function() { $http.get('/user/time/') .then(function(response) { $scope.locationTime = response.data[0].locationTime; }); 

Page:

 <html> <head> <script src="angular.min.js"></script> <script src="controller.js"></script> </head> <body onload="locTime()"> <h1>Время пользователя</h1> <script> var times = //locationTime//; console.log(times); </script> </body> </html> 

In my case, when displaying the values ​​of the angular, instead of curly brackets, double slash is used. How to display the resulting locationTime value in the console?

  • in then write console.log('LOCTIME=', response.data[0].locationTime) - nörbörnën
  • Only I must display on the page, not in the controller. Therefore, such a strange question. Is there no other way to pass a parameter from a controller to a javascript page? - Valery Orlov
  • @ValeryOrlov, and if you declare the times variable to the controller, and in the controller, assign the value to it, and then output it on the page itself. - Sergey Glazirin
  • Interesting idea. Could you give an example for clarity? - Valery Orlov
  • For all of my attempts, I get: ReferenceError: times is not defined or TypeError: Cannot read property 'times' of undefined. Whether the variable is not visible in the controller is not clear. - Valery Orlov

0