How to implement behavior subject using service in Angular 8

I’m going to show you a simple way: @Injectable() export class ProfileService { private profileObs$: BehaviorSubject<Profile> = new BehaviorSubject(null); getProfileObs(): Observable<Profile> { return this.profileObs$.asObservable(); } setProfileObs(profile: Profile) { this.profileObs$.next(profile); } } Now when you update something anywhere in the application, you can set that change by the ProfileService and each subscriber is receiving the change. … Read more

How to Upload File from Angular to ASP.NET Core Web API

my BlogController looks like this: [HttpPost] public async Task<ActionResult<Blog>> PostBlog([FromForm]PostBlogModel blogModel) It seems that you’d like to pass data using form-data, to achieve it, you can refer to the following code sample. .component.html <form [formGroup]=”newBlogForm” (ngSubmit)=”onSubmit(newBlogForm.value)”> <div> <label for=”Name”> Blog Name </label> <input type=”text” formControlName=”Name”> </div> <div> <label for=”TileImage”> Tile Image </label> <input type=”file” formControlName=”TileImage” … Read more

Angular 8 ng-build throwing MIME error with cordova

I had the same issue. Created a new project. Built a production version “build-production”: “ng build –configuration=production –extract-css=false –prod –aot” Deployed to NGINX White page with no content between tags in Chrome Element inspector Fix Update tsconfig.json “target”: “es5”, Then rebuild the application and deploy again. This solution worked for me, I now have content … Read more

Angular 8 – Lazy loading modules : Error TS1323: Dynamic import is only supported when ‘–module’ flag is ‘commonjs’ or ‘esNext’

You are using dynamic import so you have to change your tsconfig.json like this to target your code to esnext module { “compileOnSave”: false, “compilerOptions”: { “baseUrl”: “./”, “outDir”: “./dist/out-tsc”, “sourceMap”: true, “declaration”: false, “module”: “esnext”, // add this line “moduleResolution”: “node”, “emitDecoratorMetadata”: true, “experimentalDecorators”: true, “importHelpers”: true, “target”: “es2015”, “typeRoots”: [ “node_modules/@types” ], “lib”: … Read more

How do I support Internet Explorer in an Angular 8 application?

According to this issue reply You need to follow the following steps Create a new tsconfig tsconfig.es5.json next to tsconfig.json with the below contents { “extends”: “./tsconfig.json”, “compilerOptions”: { “target”: “es5” } } In angular.json Under projects:yourAppName:architect:build:configurations, add “es5”: { “tsConfig”: “./tsconfig.es5.json” } and projects:yourAppName:architect:serve:configurations add “es5”: { “browserTarget”: “yourAppName:build:es5” } Remember to change yourAppName … Read more

How should I use the new static option for @ViewChild in Angular 8?

In most cases you will want to use {static: false}. Setting it like this will ensure query matches that are dependent on binding resolution (like structural directives *ngIf, etc…) will be found. Example of when to use static: false: @Component({ template: ` <div *ngIf=”showMe” #viewMe>Am I here?</div> <button (click)=”showMe = !showMe”></button> ` }) export class … Read more