Skip to content

Missing template .html file for node_modules dependency #3274

Description

@magemello

Hi guys,

I'm having some issues with the template, not sure is related to the way how angular-cli load the dependency.

Architecture:

  • Angular 2 app generated with angular-cli
  • Angular 2 Component linked with npm int the generated app (test-component).

Description:

The generated Angular 2 app throw me the following error when I try to use the linked Angular 2 component :

VM32836:388 Unhandled Promise rejection: Failed to load test.component.html ; Zone: <root> ; Task: Promise.then ; Value: Failed to load test.component.html

.ts of the linked component

@Component({
    selector: 'test-component',
    templateUrl: './test.component.html',
    styleUrls: ['./test.component.css']
})
export class TestComponent  { }

If I change the code in the following way it works:

@Component({
    selector: 'test-component',
    template: require('./test.component.html'),
    styles: [require('./test.component.css')]
})
export class TestComponent  { }

But I can't use the require and I would like to fix the problem without introducing this change.

OS

Mac OSX

Versions.

angular-cli: 1.0.0-beta.20-4
node: 6.2.2
os: darwin x64

Activity

  1. filipesilva commented on Dec 29, 2016

    @filipesilva
    Contributor

    This seems to be an odd interaction with symlinks. Your usage is kind of peculiar though, I don't expect that to be a common case.

  2. added
    P5The team acknowledges the request but does not plan to address it, it remains open for discussion
    on Dec 29, 2016
  3. serhiisol commented on Jan 12, 2017

    @serhiisol
    Contributor

    @filipesilva I have similar problem with latest cli.

    I have ng-components package which has a lot of different components, e.g.:

    import { Component, Input } from '@angular/core';
    
    @Component({
      selector: 'otto-tooltip',
      templateUrl: 'tooltip.component.html',
      styleUrls: ['tooltip.component.sass']
    })
    export class TooltipComponent {
      @Input() title: string;
      @Input() show: boolean = false;
    }
    

    I import it from node_modules like: import {TooltipComponent} from 'ng-components/tooltip';

    Angular cli 21 used ````angular2-template-loader``` to replace template url and style urls to template with require.

    So at this point it seems like it's impossible to write 3rd party components for reusability with latest cli, of course If they won't have inline html and css, which is quite ugly.

  4. filipesilva commented on Feb 13, 2017

    @filipesilva
    Contributor

    Dupe of #1624

  5. 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.

  6. 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

    Labels

    P5The team acknowledges the request but does not plan to address it, it remains open for discussiontype: bug/fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions