我有一个Angular应用程序,当我在开发环境(npm run build
)中构建此应用程序时,它工作得很好。无法运行angular-cli命令来构建生产
但是当我尝试建立与生产标签时,出现此错误:
C:/Users/1234/app/src/$$_gendir/app/app.component.ngfactory.ts (617,85): Property 'router' is private and only accessible within class 'AppComponent'.
我知道路由器是私有的(在下面的代码),但它是如何发展的情况下工作正常,并没有但AppComponent.html应该能够使用它?
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
constructor(private router: Router, private _cookieService:CookieService) {
//some function
}
}
在此处报告了类似问题:https://github.com/angular/angular/issues/15451 – undefined
您是否直接在模板中访问'router'? – jonrsharpe
是的..我使用路由器直接进入模板app.component.html – undefined