Questions tagged [angular5]

Questions about Angular version 5, the web framework from Google. Use this tag for Angular questions which are specific to only version 5. Use tag Angular for any Angular questions which are not specific to an individual version.

Questions about Angular version 5, the web framework from Google.

You can read more about Angular version 5 here

You can find Angular version 5 official documents here

6545 questions
72
votes
2 answers

How to do a timer in Angular 5

I'm using Angular 5. I want to know how can I start timing when a 'play' button is pressed, in order to know how much time has passed since I clicked. I'd also like to know if it's possible to stop the timer and then be able to continue with the…
Samuel
  • 816
  • 1
  • 7
  • 13
71
votes
6 answers

How override Provider in Angular 5 for only one test?

In one of my unit test files, I have to mock several times the same service with different mocks. import { MyService } from '../services/myservice.service'; import { MockMyService1 } from '../mocks/mockmyservice1'; import { MockMyService2 } from…
hbaltz
  • 711
  • 1
  • 5
  • 4
67
votes
9 answers

How to get base url in angular 5?

My current url is http://localhost:4200/test/dashboard. I want to print base url i.e http://localhost:4200 using angular 5 features.
him
  • 3,325
  • 3
  • 14
  • 17
64
votes
7 answers

How to mat-button-toggle by default selected in angular

How can I set default selected last button in toggle group. This is my code. Heritage
Hossein Bajan
  • 2,644
  • 5
  • 19
  • 36
64
votes
6 answers

Read a file and parse its content

I have file upload control which holds the selected file as below,
I have a submit button as below,
63
votes
6 answers

Load new modules dynamically in run-time with Angular CLI & Angular 5

Currently I'm working on a project which is being hosted on a clients server. For new 'modules' there is no intention to recompile the entire application. That said, the client wants to update the router/lazy loaded modules in runtime. I've tried…
Lars Meijdam
  • 1,177
  • 1
  • 10
  • 18
62
votes
8 answers

When upgrading Angular 5 to 6, I get incompatible peer dependency (using ng update @angular/core)

I am trying to update my Angular app from v5 to v6 following this guide. I have ran all these commands successfully: npm install -g @angular/cli npm install @angular/cli ng update @angular/cli The problem is that I get an error when running this…
Ahmed Elkoussy
  • 8,162
  • 10
  • 60
  • 85
61
votes
4 answers

Angular 5 service failing to pass unit tests with (NullInjectorError: No provider for HttpClient!)

I keep getting the following errors when running unit tests Error: StaticInjectorError(DynamicTestModule)[ApiService -> HttpClient]: StaticInjectorError(Platform: core)[ApiService -> HttpClient]: NullInjectorError: No provider for…
user6885115
60
votes
8 answers

How to add data dynamically to mat-table dataSource?

I have data streaming from backend and i see it printing in console now i am trying to push event to dataSource its throwing error dataSource is not defined. Can someone help how to dynamically add data to materialize table…
hussain
  • 6,587
  • 18
  • 79
  • 152
56
votes
6 answers

Web API Error - This request has been blocked; the content must be served over HTTPS

We have deployed the api on azure and trying to consume in our web app written in angular 5. However when we try to consume the api we are getting following errors. Chrome Mixed Content: The page at…
XamDev
  • 3,377
  • 12
  • 58
  • 97
55
votes
8 answers

RangeError: Maximum call stack size exceeded when using valueChanges.subscribe

I am using Angular 5 with Reactive forms and need to make use of the valueChanges in order to disable required validation dynamically component class: export class UserEditor implements OnInit { public userForm: FormGroup; userName:…
dfmetro
  • 4,462
  • 8
  • 39
  • 65
53
votes
1 answer

Angular service decorator providedIn root effect on lazy loading

I am wondering how the new angular service decorator @Injectable({ providedIn: 'root' }) works in conjuction with lazy loading. Meaning if I have a lazy loaded module, with a service that is providedIn root, will this include the specific…
Karl Johan Vallner
  • 3,980
  • 4
  • 35
  • 46
52
votes
7 answers

Angular 5 Mat-grid list responsive

i created grid list with column 6 and i want to be grid title take 100% width on small screen devices. Now it creates 6 column on small screens as well Expected: One grid-title occupies 100% of space on mobile device only
Somnath Swami
  • 591
  • 1
  • 4
  • 13
51
votes
2 answers

In Angular, how to remove the current route from history on navigation?

In my app I have a category page that has links to a various product list pages. If it turns out that when you get to a product list page there is only one product then it automatically navigates to that product detail page. What I want is to…
HisDivineShadow
  • 1,036
  • 1
  • 12
  • 21
51
votes
4 answers

ng generate component in subdirectory

I have the following directory structure I would like to create a new page, let's say, an About page. I want to put it in src/app/page/about/* So I try: ng generate component pages/about but I get this error: Error: More than one module matches.…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817