Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

214
Visualizações
Not able to run angular-cli command to build production

I have an Angular app, when I build this app in development environment (npm run build) it works completely fine.

But when I try to build with production tag, it fails with this error:

C:/Users/1234/app/src/$$_gendir/app/app.component.ngfactory.ts (617,85): Property 'router' is private and only accessible within class 'AppComponent'.

I know router is private (in below code), but how is it working fine for development instance, and none but AppComponent.html should be able to use that?

@Component({
    selector: 'my-app',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
})

export class AppComponent {
    constructor(private router: Router, private _cookieService:CookieService) {
        //some function
    }
}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Production build is stricter and thus doesn't let you access private objects outside of scope. You app.component.html will not be able to access router directly. You could write a public function in your app component and call the private router from within.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda