As someone diving into the world of Angular and JavaScript, I am tackling the challenge of creating a directive that requires adding an array to the directive's scope. Here's a snippet of the code for my directive:
.directive("startupSections", function(){
return {
restrict: "E",
transclude: true,
scope: {
title: "@",
sections: [1,2,3]
},
link: function(scope, elem, attrs){
console.log (scope);
}
}
});
However, upon execution, I encounter the following error:
TypeError: definition.match is not a function
at angular.js:7992
at forEach (angular.js:417)
at parseIsolateBindings (angular.js:7987)
at parseDirectiveBindings (angular.js:8028)
at addDirective (angular.js:9984)
at collectDirectives (angular.js:9142)
at compileNodes (angular.js:8974)
at compileNodes (angular.js:8990)
at compileNodes (angular.js:8990)
at compile (angular.js:8859)
If I use a string or number instead of an array for the value of "sections," the error disappears. How can I properly assign an array as the value of a property in the scope?