angular-cli server – how to specify default port

Update for @angular/cli@9.x: and over In angular.json you can specify a port per “project” “projects”: { “my-cool-project”: { … rest of project config omitted “architect”: { “serve”: { “options”: { “port”: 1337 } } } } } All options available: https://angular.io/guide/workspace-config#project-tool-configuration-options Alternatively, you may specify the port each time when running ng serve like this: … Read more

How to iterate using ngFor loop Map containing key as string and values as map iteration

For Angular 6.1+ , you can use default pipe keyvalue ( Do review and upvote also ) : <ul> <li *ngFor=”let recipient of map | keyvalue”> {{recipient.key}} –> {{recipient.value}} </li> </ul> WORKING DEMO For the previous version : One simple solution to this is convert map to array : Array.from Component Side : map = … Read more

“Error: No provider for router” while writing Karma-Jasmine unit test cases

You need to import RouterTestingModule when setting up the test module. /* tslint:disable:no-unused-variable */ import { async, ComponentFixture, TestBed } from ‘@angular/core/testing’; import { By } from ‘@angular/platform-browser’; import { DebugElement } from ‘@angular/core’; import { RouterTestingModule } from ‘@angular/router/testing’; import { MyNewComponentComponent } from ‘./my-new-component.component’; describe(‘MyNewComponentComponent’, () => { let component: MyNewComponentComponent; let fixture: … Read more

Message “the term ‘ng’ is not recognized as the name of a cmdlet”

The first path in the path variable needs to be the NPM path. Opening the Node.js command prompt I found that the ng command worked there. I dug into the shortcut and found that it references a command to ensure the first Path variable is NPM. To Fix: Right Clicked on My Computer (windows) Selected … Read more

How to change Angular CLI favicon

Make a png image with same name (favicon.png) and change the name in these files: index.html: <link rel=”icon” type=”image/x-icon” href=”https://stackoverflow.com/questions/40817280/favicon.png” /> angular-cli.json: “assets”: [ “assets”, “https://stackoverflow.com/questions/40817280/favicon.png” ], And you will never see the angular default icon again. Size should be 32×32, if more than this it will not display. NOTE: This will not work with … Read more