Angular.js: directive name should be trimmed

Created on 22 Mar 2015  ·  3Comments  ·  Source: angular/angular.js

Directive name should probably be either trimmed or angular should throw an exception, so a typo is easier to spot. Leading or following space is clearly an error.

In the following example the name is 'directiveName ' instead of 'directiveName':

https://jsfiddle.net/c2ztgdjr/

Maybe same rule should be applied to controllers, factories etc, although it's still possible to inject those with an extra space.

PRs plz! $compile low confusing

Most helpful comment

Be careful not to have an upper case character at the beginning of your component name.

All 3 comments

I would say we should throw. This would be an easy fix in the compiler, see https://github.com/angular/angular.js/blob/74eb17d7c8232f72f134bf2546f10fed7234d276/src/ng/compile.js#L800

Anyone fancy sending a PR with an associated test?

@pkozlowski-opensource Hey! Please check the PR for this issue. Thanks!

Be careful not to have an upper case character at the beginning of your component name.

Was this page helpful?
0 / 5 - 0 ratings