0
$scope.dates = new Date();
var ed = new Date($filter('date')($scope.dates,'hh:mm:ss'));

in the second line I want to get time, but I get reference error.

What is my problem?

 (function(){

var app = angular.module('notesApp',['angular-markdown-editable']);

 app.controller('notesController', function($scope, $interval){

function updateTime() {
  $scope.dates = new Date();
  var ed = new Date($filter('date')($scope.dates,'hh:mm:ss'));
  alert(ed);
      }
...
4
  • can you show us the controller or directive or service definition? I would need to see how you are injecting $fitler Commented Jul 9, 2015 at 22:09
  • @Dalorzo I do it in function Commented Jul 9, 2015 at 22:12
  • I need to see the angular component declaration Commented Jul 9, 2015 at 22:13
  • answer provided below Commented Jul 9, 2015 at 22:19

1 Answer 1

2

You need to inject $filter in your controller declaration like:

app.controller('notesController', function($scope, $interval, $filter){ // <-- filter was added at the end

I understand this issue is about angular but I would advise that you consider using javascript date functions like:

var date = new Date();
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hour = date.getHours();
Sign up to request clarification or add additional context in comments.

Comments

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.