angular6

Angular CLI 6 - ng build doesn't produce Server bundles

非 Y 不嫁゛ 提交于 2019-12-10 20:10:05
问题 I am following the official Angular Universal guide available at https://angular.io/guide/universal but when I run ng build --prod it does produce client bundles but doesn't produce server bundles. Since my environment is ASP.Net Core, I have skipped Universal Webpack configuration and server.ts . With previous version of Angular CLI we were able to build server bundle by specifying app while building ng build --app=ssr Am I missing something? Can anyone please help? 回答1: Fix: One thing

Browser tab close event in angular 6 only works in debug mode

两盒软妹~` 提交于 2019-12-10 19:30:19
问题 I am trying to capture browser events like tab-close and refresh in my angular 6 Application. It's working fine in debug mode but its not working if I close debug mode and run the application. below is the piece of code registerDOMEvents() { window.addEventListener('unload', () => { if (this.validNavigation === 0) { this.endSession(); } }); document.addEventListener('keydown', (e) => { const key = e.which || e.keyCode; if (key === 116) { this.validNavigation = 1; } }); } endSession() { this

Angular 6 + Popper.js (without jQuery)

家住魔仙堡 提交于 2019-12-10 18:03:53
问题 I am trying to setup Popper.js to work with angular 5, without bootstrap or jquery. I tried following this https://github.com/FezVrasta/popper.js/#react-vuejs-angular-angularjs-emberjs-etc-integration, but it is not exactly a point A to B description for angular applications. I installed Popper.js via npm npm install popper.js --save then I chose to bundle the esm module to my angular-cli scripts "scripts": [ (...) "../node_modules/popper.js/dist/esm/popper.js" ], Since esm/popper.js exports

Changing top level routes for multiple Angular apps served from single nginx server?

断了今生、忘了曾经 提交于 2019-12-10 17:55:58
问题 My current configuration is as follows: I have two separate Angular apps on different Docker containers running on different ports, for example, 4200 and 4201. I access them both directly through their ports: www.myserver.com:4200 and www.myserver.com:4201. They are created using the following docker-compose config file: version: '3.6' services: app1: build: context: ../app1 dockerfile: Dockerfile command: bash -c "ng serve --host 0.0.0.0 --port 4200" ports: - "4200:4200" app2: build: context

Angular 6 Required only one field from many fields Reactive Form

╄→гoц情女王★ 提交于 2019-12-10 17:21:42
问题 I am new in angular. I have one scenario where I need only one field required from 5 fields in the form, means if the user fills at least one field then form makes valid. Thanks in advance. 回答1: Since you need to check for the validity of whole form only if one of the fields is non empty , You can manually set the validity like below : if(!this.valid){ this.form.setErrors({ 'invalid': true}); }else{ this.form.setErrors(null); } Where this.valid is your condition based on which you can set the

How to include external html files and js file in Angular 6?

£可爱£侵袭症+ 提交于 2019-12-10 16:26:44
问题 I want to include some html files and use functions in some external js files in my Angular 6 project. How can I include external html file and js file in Angular 6? 回答1: You can place those files under src/assets folder and specify the path in angular.json . Meaning, you can keep the files to be included under src/assets/html and src/assets/js folders. angular.json configuration like : "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist/browser",

Router navigate to child route - Angular 6

那年仲夏 提交于 2019-12-10 15:44:27
问题 I've defined my routes like this: const routes: Routes = [ { path: '', loadChildren: './tabs/tabs.module#TabsPageModule' }, { path: 'faq', loadChildren: './faq/faq.module#FaqPageModule' }, { path: 'terms', loadChildren: './terms/terms.module#TermsPageModule' } ]; @NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule] }) export class AppRoutingModule {} and like this: const routes: Routes = [ { path: 'tabs', component: TabsPage, children: [ { path: '', redirectTo: '/tabs/

can't use directive declared inside app module in child modules in Angular 6

只愿长相守 提交于 2019-12-10 15:08:54
问题 I'm using Angular 6 . I have declared a directive StickyPopover by extending NbgPopover and have added in declaration of app.module.ts import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { AppRoutingModule } from './app-routing.module'; import { AuthLayoutComponent } from './layouts/auth-layout/auth-layout.component'; import {AdminLayoutComponent} from './layouts/admin-layout/admin-layout

HTTP get call in Angular 6

点点圈 提交于 2019-12-10 14:05:10
问题 I updated my Angular project to Angular 6 and don't know how to do http get requests. Thats how I did it in Angular 5: get(chessId: string): Observable<string> { this.loadingPanelService.text = 'Loading...'; this.loadingPanelService.isLoading = true; const url = `${this.apiPathService.getbaseUrl()}api/chess/${chessId}/rating`; return this.http.get<string>(url) .catch((error) => { console.error('API error: ', error); this.loadingPanelService.isLoading = false; this.notificationService

Angular `ng update @angular/…` returns `401 Unauthorized`

吃可爱长大的小学妹 提交于 2019-12-10 13:20:25
问题 npm -v returns 6.0.0 node -v returns v10.0.0 Angular CLI local and global version is 6.0.0 I create a new package with ng new sample , run npm install without issue, and then I try ng update @angular/core or ng update @angular/cli and get 401 Unauthorized in response. Trying to run update on an already Angular 6 repository does seem redundant but I also have this issue with an Angular 5 repository. I don't have a lot to go on from this error, is it something to do specifically with ng update