Reputation: 19324
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
?
Upvotes: 0
Views: 412
Reputation: 106483
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
.
Upvotes: 3