Skip to content

Cryptic error when # included in templateUrl #3543

Closed

Description

@jessegood

Not sure how common this will be but I ran into a cryptic error when a # is included in the string to templateUrl. Simple example:

@Component({
  selector: 'app',
 })
@View({
  templateUrl: `
    <p #p>Hello</p>
  `
})
export class App {}

In the above example, it was just a goof and I forgot to change templateUrl to template.
Without the # you get a nice error message:

EXCEPTION: Failed to load the template for "App" : Failed to fetch url "http://127.0.0.1:8080/

Hello

With the # you get this:
Firefox:

EXCEPTION: TypeError: parts is null

Chrome:

EXCEPTION: TypeError: Cannot read property '1' of null

From what I've found the same error happens with any string that has a # in it.

Activity

  1. pkozlowski-opensource commented on Aug 8, 2015

    @pkozlowski-opensource
    Member

    In reality it is a combination of # and a new line in the URL. Dart version doesn't suffer from this pb, as a URL gets encoded before matching. Will try to do the same on JS side to bring 2 implementations to the same level.

  2. added a commit that references this issue on Aug 8, 2015
    92e0e65
  3. added a commit that references this issue on Aug 15, 2015
    8832c99
  4. angular-automatic-lock-bot commented on Sep 6, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  5. locked and limited conversation to collaborators on Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions