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

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -