1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
//... |
Category Angular 5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// service downloadFile(id: number): Observable<Blob>{ return this.http.get(`downloadurl` + id,{ responseType: 'blob' }); } //import in top of ts file import { saveAs } from 'file-saver'; // compoment ... |
1 2 3 |
setTimeout(()=>{ // your code }, 10000); |
It might be related to corruption in Angular Packages or incompatibility of packages.
Please follow the below steps to solve the issue.
- Delete node_modules folder manually.
- Install Node ( https://nodejs.org/en/download ).
- Install Yarn ( https://yarnpkg.com/en/docs/install ).
- Open command prompt , go to path angular folder and run Yarn.
- Run angular\nswag\refresh.bat.
- Run npm start from the angular folder.
Update
ASP.NET Boilerplate suggests here to use yarn because npm has some problems. It is slow and can not consistently resolve dependencies, yarn solves those problems and it is compatible to npm as well.
Build for production
1 |
ng build --prod=true |
Build for dev
1 |
ng build --env=cbdev --aot=true --output-hashing all |
Run project using different port
1 |
ng serve --port 4401 |
Create component
1 |
ng generate component name |
Create module
1 |
ng generate... |
First Step:
Run the command
1 |
ng build |
or
1 |
ng build -prod (then it will compact all files for production version) |
Second Step:
Change in index.html
1 |
<base href="/"> to <base href="./"> |
Third Step:
Put all files into server(may be htdocs in localhost or any server)
Method — 1
In app.module.ts:
- Add imports:
1 |
import { HashLocationStrategy, LocationStrategy } from '@angular/common'; |
And in NgMoudle provider, add:
1 |
{provide: LocationStrategy, useClass: HashLocationStrategy} |
Example (app.module.ts):
Add this line in index.html file
1 2 3 |
#toast-container > div { opacity:1; } |
1 2 |
<div *ngFor="let latestblog of latestblogdata; index as i" [ngClass]="(i==0)?'item active':'item'"> </div> |