javascript - AngularJS: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode -
so had directive:
app.directive('customdropdown', function() { return { restrict: 'e', templateurl: '/static/templates/directive_templates/customdropdown.html', link: function(scope, element, attrs) { console.log(attrs.custom-class); } } })
markup:
<custom-dropdown custom-class="custom-select-menu"> </custom-dropdown>
but, due console.log(attrs.custom-class)
error mentioned in question. goes away when change custom-class
custom
. idea why error popping up? can't use hyphens?
attrs.custom-class
custom-class not valid identifier in javascript. have 2 choices :
rename custom-class else without hypen.
use bracket syntax :
attrs['custom-class']
Comments
Post a Comment