Solucionado (ver solução)
Solucionado
(ver solução)
5
respostas

'app' is not a known element

Boa noite. O fonte da aula 1 roda normalmente. Mas se eu acrescentar os códigos da aula 2 recebo os erros citados abaixo.

Unhandled Promise rejection: Template parse errors:
'app' is not a known element:
1. If 'app' is an Angular component, then verify that it is part of this module.
2. If 'app' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. ("
    </head>
    <body>
        [ERROR ->]<app>Carregando...</app>
    </body>
</html>
"): FotoComponent@23:8 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors:
'app' is not a known element:
1. If 'app' is an Angular component, then verify that it is part of this module.
2. If 'app' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. ("
    </head>
    <body>
        [ERROR ->]<app>Carregando...</app>
    </body>
</html>
"): FotoComponent@23:8
    at TemplateParser.parse (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:8530:21)
    at RuntimeCompiler._compileTemplate (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:16905:53)
    at eval (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:16828:85)
    at Set.forEach (native)
    at compile (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:16828:49)
    at ZoneDelegate.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:192:28)
    at Zone.run (http://localhost:3000/node_modules/zone.js/dist/zone.js:85:43)
    at http://localhost:3000/node_modules/zone.js/dist/zone.js:451:57
    at ZoneDelegate.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:225:37)
    at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:125:47) Error: Template parse errors:
'app' is not a known element:
1. If 'app' is an Angular component, then verify that it is part of this module.
2. If 'app' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. ("
    </head>
    <body>
        [ERROR ->]<app>Carregando...</app>
    </body>
</html>
"): FotoComponent@23:8
    at TemplateParser.parse (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:8530:21)
    at RuntimeCompiler._compileTemplate (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:16905:53)
    at eval (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:16828:85)
    at Set.forEach (native)
    at compile (http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:16828:49)
    at ZoneDelegate.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:192:28)
    at Zone.run (http://localhost:3000/node_modules/zone.js/dist/zone.js:85:43)
    at http://localhost:3000/node_modules/zone.js/dist/zone.js:451:57
    at ZoneDelegate.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:225:37)
    at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:125:47)

Error: Uncaught (in promise): Error: Template parse errors:
'app' is not a known element:
1. If 'app' is an Angular component, then verify that it is part of this module.
2. If 'app' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. ("
    </head>
    <body>
        [ERROR ->]<app>Carregando...</app>
    </body>
</html>
"): FotoComponent@23:8
    at resolvePromise (zone.js:418)
    at resolvePromise (zone.js:403)
    at zone.js:451
    at ZoneDelegate.invokeTask (zone.js:225)
    at Zone.runTask (zone.js:125)
    at drainMicroTaskQueue (zone.js:357)
    at XMLHttpRequest.ZoneTask.invoke (zone.js:297)

Seguem os fontes:

import {Component} from '@angular/core';

@Component ({
    moduleId: module.id,
    selector:'app',
    templateUrl: './app.component.html'
})
export class AppComponent {}
import {Component} from '@angular/core';

@Component({
    moduleId: module.id,
    selector: 'foto',
    templateUrl: './foto.component.html'
})
export class FotoComponent {}
import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent }   from './app.component';
import { FotoModule } from './foto/foto.module';

@NgModule({
  imports:      [ BrowserModule, FotoModule ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }
<img class="img-responsive center-block" src="img/leao.jpg" alt="Leão">
import { NgModule }      from '@angular/core';
import { FotoComponent }   from './foto.component';

@NgModule({
  declarations: [ FotoComponent ],
  exports: [FotoComponent]
})
export class FotoModule { }
5 respostas

Testei aqui e funcionou. Você fez as alterações com o compilador em tempo real funcionando?

Sim. Instalei tudo de novo, mas sem sucesso. Vou tentar em outra máquina.

Comece do zero. Esse erro indica que não existe AppComponent, mas ele é o padrão do Angular e já existe por padrão.

Se você tem Git coloca o projeto nele e passe o link. Se puder colar tudo que está no terminal de mensagem de erro ajuda.

solução!

Flavio, encontrei o problema. Eu criei o arquivo com um espaço ("app.[aqui]component.html"). Tirei o espaço e funcionou. Muito obrigado pela paciência.

Excelente notícia! Agora é continuar com os estudos. Obrigado por me informar.