angular6

Angular 6 does not add X-XSRF-TOKEN header to http request

自作多情 提交于 2019-11-28 08:29:59
I've read the docs and all the related questions on SO, but still Angular's XSRF mechanism isn't working for me: in no way I can make a POST request with the X-XSRF-TOKEN header appended automatically. I have an Angular 6 app with a login form. It's part of a Symfony (PHP 7.1) website, and the Angular app page, when served from Symfony, sends the correct Cookie ( XSRF-TOKEN ): My app.module.ts includes the right modules: // other imports... import {HttpClientModule, HttpClientXsrfModule} from "@angular/common/http"; // ... @NgModule({ declarations: [ // ... ], imports: [ NgbModule.forRoot(),

Property 'from' does not exist on type 'typeof Observable', angular 6?

馋奶兔 提交于 2019-11-28 04:27:37
问题 I updated my angular 5.2.10 project to angular 6. I did step by step https://update.angular.io/ , everything is OK unless Observable.from In a service I used Observable.from(this.user) as following: import { Observable } from 'rxjs/Observable'; ... Observable.from(this.users)// this.users is an array It was OK, but in angular 6 the following error occurred Property 'from' does not exist on type 'typeof Observable' I changed it as follows import { Observable, from } from 'rxjs'; But no change

In Angular 6 how make case insensitive url pattern?

自古美人都是妖i 提交于 2019-11-28 03:32:35
问题 In my case I want to support same url in case insensitive manner. Example: it should support all url localhost:1029/documentation localhost:1029/DOCUMENTATION localhost:1029/DOCUMENTAtion localhost:1029/docuMENTATION 回答1: You should add this provide statement to the app.module.ts import { DefaultUrlSerializer, UrlTree } from '@angular/router'; export class LowerCaseUrlSerializer extends DefaultUrlSerializer { parse(url: string): UrlTree { // Optional Step: Do some stuff with the url if needed

(Angular 6) Angular Universal - Not waiting on content API call

馋奶兔 提交于 2019-11-27 23:45:26
问题 Cannot get SSR to work when using Angular Universal with pages that use dynamic content. All other pages work and the dynamic pages return with HTML but do not include the dynamic data. Method Called: ngOnInit() { const div = this.renderer.createElement('div'); const texttest = this.renderer.createText('this works'); this.renderer.appendChild(div, texttest); this.renderer.appendChild(this.content.nativeElement, div); this.createLinkForCanonicalURL(); // The HTML never shows, the method works

What is the purpose of providedIn with the Injectable decorator when generating Services in Angular 6?

断了今生、忘了曾经 提交于 2019-11-27 19:57:27
问题 When generating services in the Angular CLI, it is adding extra metadata with a 'provided in' property with a default of 'root' for the Injectable decorator. @Injectable({ providedIn: 'root', }) What exactly does providedIn do? I am assuming this is making the service available like a 'global' type singleton service for the whole application, however, wouldn't be cleaner to declare such services in the provider array of the AppModule? UPDATE: For anyone else, the following paragraph provided

angular 6 - best practice of sharing common code between projects

江枫思渺然 提交于 2019-11-27 18:38:29
问题 How to share code between projects ? I have two apps created using: ng generate application app1 ng generate application app2 I want projects/app1/src/app.module.ts to import a module from projects/app2/src/shared/common.module.ts What is the best practice for this without creating a 3rd project called common or something ? Create a projects/common or just have a folder called common and plate TypeScript files here and import them. 回答1: Use library projects! ng generate library common This

How to uninstall angular packaged library

人走茶凉 提交于 2019-11-27 16:31:52
I have installed example-app.tgz using this command npm install --save example-app.tgz but i can not uninstall this library So how to uninstall this npm package? Not working npm uninstall --save ../example-app.tgz Try this: 1) npm uninstall example-ng-lib-app --save 2) or delete node_modules directory (you might need to kill the app first). remove the example-ng-lib-app from package.json in your root directory. run command: npm install 来源: https://stackoverflow.com/questions/57474470/how-to-uninstall-angular-packaged-library

How to find img tag in angular 7

十年热恋 提交于 2019-11-27 16:31:32
How to find image tag in file .I have tried but not working.I do not know how to convert images for my application. <img src="./assets/images/test1.png" width="250" height="200"> <div class="power"></div> In order to do this, we will need to execute a Node script that will search for any image URL inside the HTML & CSS files using Regex. After that, it will replace these URLs with their Base64 values. First thing, we need to install these NPM packages that will make our life easier: npm install replace-in-file --save-dev npm install datauri --save-dev We will use the first one to find the

Angular 6 - process is not defined when trying to serve application

被刻印的时光 ゝ 提交于 2019-11-27 16:22:26
问题 I am getting the following error when I try to serve my angular 6 application using cosmicjs: Uncaught ReferenceError: process is not defined at Object../node_modules/cosmicjs/dist/index.js (index.js:6) at __webpack_require__ (bootstrap:81) at Object../src/app/app.component.ts (main.js:94) at __webpack_require__ (bootstrap:81) at Object../src/app/app.module.ts (app.component.ts:9) at __webpack_require__ (bootstrap:81) at Object../src/main.ts (environment.ts:18) at __webpack_require__

Angular Service Worker SwUpdate.available not triggered

痞子三分冷 提交于 2019-11-27 15:49:37
问题 I'm having a hard time integrating angulars service worker into my application. I followed the guide and it works so far. I can create a shortcut on my homescreen and launch into my app. The problem is that my app somehow doesn't update. If I change the name of a button, build the app and put it onto my server the app still shows the old version until I hit F5 (restarting the app doesn't help either). I tried to put the following code into my ngOnInot of my app but it didn't help ngOnInit() {