I have created one directive and use scope variables in this way:
<div data-create-instants-since-beginning data-daysnum="daysnum" data-tostore="tostore">
I want when tostore is undefined to set it to empty array but unfortunately this not working.
.directive("createInstantsSinceBeginning", function () {
return {
scope: {
daysnum: "=",
tostore: "="
},
link: function ($scope, element) {
if (typeof $scope.tostore == 'undefined') {
$scope.$apply(function () {
$scope.tostore = [];
});
}
// other code ..
How I can solve the problem?
Best regards.