angular6

Angular 6 Http Interceptors, request headers not modified

本小妞迷上赌 提交于 2019-12-02 19:47:48
问题 I created an interceptor to add an authorization header to each request sent by the client, here is the code : import { HttpInterceptor, HttpRequest, HttpHandler, HttpHeaderResponse, HttpSentEvent, HttpProgressEvent, HttpResponse, HttpUserEvent, HttpEvent, HttpHeaders } from "@angular/common/http"; import { Observable } from "rxjs"; import { Injectable } from "@angular/core"; @Injectable() export class AuthenticationInterceptor implements HttpInterceptor { intercept(req: HttpRequest<any>,

Errors: Data path “.builders['app-shell']” should have required property 'class'

做~自己de王妃 提交于 2019-12-02 18:40:24
I am getting this error while running my application. Here are the details of my application. I have already tried cache clean. idirene youcef In your package.json change the devkit builder. "@angular-devkit/build-angular": "^0.800.1", to "@angular-devkit/build-angular": "^0.10.0", it works for me. good luck. Following worked for me npm uninstall @angular-devkit/build-angular npm install @angular-devkit/build-angular@0.13.0 Your @angular-devkit is incompatible with @angular/cli version, so just install older one like this for example: npm install @angular-devkit/build-angular@0.13.8 @angular

Angular 6 Unit Tests: An error was thrown in afterAll\\nReferenceError: Can't find variable: $ thrown

本小妞迷上赌 提交于 2019-12-02 18:06:59
When running my unit tests, from time to time, even if they pass, at the end of all the tests running, I will get the following error. On my Jenkins CI build running PhantomJS: .PhantomJS 2.1.1 (Linux 0.0.0) ERROR { "message": "An error was thrown in afterAll\nReferenceError: Can't find variable: $ thrown", "str": "An error was thrown in afterAll\nReferenceError: Can't find variable: $ thrown" } Or on Chrome: Chrome 67.0.3396 (Windows 7 0.0.0) ERROR { "message": "An error was thrown in afterAll\n[object ErrorEvent] thrown", "str": "An error was thrown in afterAll\n[object ErrorEvent] thrown" }

Jquery not working in angular 6 Error: ENOENT: no such file or directory, open '…\\node_modules\\jquery\\dist\\jquery.min.js'

走远了吗. 提交于 2019-12-02 18:03:18
I am in process migrating Angular 5 project to Angular 6. While starting application by npm start getting the below error ** Angular Live Development Server is listening on localhost: 9000, open your browser on http://localhost:9000/ ** 91% additional asset processing scripts-webpack-plugin× 「wdm」: Error: ENOENT: no such file or directory,open'\trunk\node_modules\jquery\dist\jquery.min.js' I tried npm install jquery --save npm install @types/jquery --save Nothing is working I checked my node modules folder I can able to see the jquery file Pasted my package.json and angular.json below package

Http Error Handling in Angular 6

匆匆过客 提交于 2019-12-02 16:42:24
I, am trying to handle the http error using the below class in angular 6. I got a 401 unAuthorized status from server. But however I, don't see the console error message. HttpErrorsHandler.ts file import { ErrorHandler, Injectable} from '@angular/core'; @Injectable() export class HttpErrorsHandler implements ErrorHandler { handleError(error: Error) { // Do whatever you like with the error (send it to the server?) // And log it to the console console.error('It happens: ', error); } } app.module.ts file providers: [{provide: ErrorHandler, useClass: HttpErrorsHandler}], HttpCallFile import {

Navigate from Login page to Tabs in Ionic4?

拜拜、爱过 提交于 2019-12-02 13:10:53
I am creating an application and i want move from login Page to Tabs Page. When I try to navigate to Tabs page, its only showing Home page without Tabs. here is my Code. app-routing.module.ts import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; const routes: Routes = [ { path: '', redirectTo: 'login', pathMatch: 'full' }, { path: 'login', loadChildren: './pages/login/login.module#LoginPageModule' }, { path: 'tabs', loadChildren: './pages/tabs/tabs.module#TabsPageModule' } ]; @NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule

Module not found ..Cannot resolve module 'rxjs/operators/toPromise with Angular6

社会主义新天地 提交于 2019-12-02 13:10:25
I am receiving an error when trying to build my application using angular 6 and have no idea what to do. Module rxjs not found see this Module not found ..Cannot resolve module 'rxjs/operators/toPromise what should i do ? // the contact.service.ts import { Injectable } from '@angular/core'; import { Contact } from './contact'; import { Http, Response } from '@angular/http'; import 'rxjs/add/operator/toPromise'; @Injectable() export class ContactService { private contactsUrl = '/api/contacts'; constructor (private http: Http) {} ....... } try to remove the import statement. It should work

Cannot get relative image path in angular 6

谁说我不能喝 提交于 2019-12-02 12:58:54
This is the structure of my folders angular-src --src --app ----components ------whatever.html public --images ----01.jpg I want to access 01.jpg from whatever.html . I tried many alternatives like <img src="../../../../public/images/01.jpg"> or <img src="../../../../../public/images/01.jpg"> and I keep getting 404. I use angular 6 and node 8.11.1. What am I missing here? Thanks At first you should move your assets like the img you use into the assets folder which is a direct child of src. You should then be able to call the image directly by <img src="assets/images/01.jpg"> In your .angular

Change form elements using angular form

落花浮王杯 提交于 2019-12-02 12:01:02
I am making angular dynamic form with form-elements loaded through JSON.. The form element generation are working fine, but i am in the need of change of form elements based on options selected from dropdown.. JSON that generates form-elements jsonData: any = [ { "elementType": "textbox", "class": "col-12 col-md-4 col-sm-12", "key": "project_name", "label": "Project Name", "type": "text", "value": "", "required": false, "minlength": 3, "maxlength": 20, "order": 1 }, { "elementType": "dropdown", "key": 'project', "label": 'Choose option to display', "options": [ { "key": 'description', "value":

What is the function of --poll flag in CLI

你。 提交于 2019-12-02 11:27:02
I was searching a solution for an issue which is in my angular project, ng serve --watch was not detecting changes in some of the files. And I got a solution which says use --poll=2000 It really worked. But there are no clear information available about the function of flag poll . In cases where Angular CLI is running in a shared directory on linux VM on a windows host the webpack dev server isn't detecting file changes from the host environment. (ex: Whenever a docker dev environment is running on a windows host.) This is solved by adding poll option to the webpack dev server configuration.