0

If i set a scope variable like this it works just fine:

$scope.event = new Date();

but if i set this, i get an undefined error:

$scope.event.start.time = new Date();

Why and how can I set $scope.event.start.time?

1 Answer 1

3

With something like this:

$scope.event = {
  start: {
    time: new Date()
  }
};

Otherwise, as JS doesn't have auto-vivification, you'll attempt to access (set) a property of undefined.

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

1 Comment

Ahh that makes sense. I got spoiled with just making up variables in the view.

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.