6,529 questions
234
votes
11
answers
177k
views
Expected validator to return Promise or Observable
I'm trying to do a custom validation on Angular 5 but I'm facing the following error
Expected validator to return Promise or Observable
I just want to return an error to the form if the value doesn't ...
229
votes
20
answers
269k
views
Angular 5 - Copy to clipboard
I am trying to implement an icon that when clicked will save a variable to the user's clipboard. I have currently tried several libraries and none of them have been able to do so.
How do I properly ...
229
votes
16
answers
445k
views
Set focus on <input> element
I am working a front-end application with Angular 5, and I need to have a search box hidden, but on click of a button, the search box should be displayed and focused.
I have tried a few ways found on ...
211
votes
45
answers
745k
views
Angular CLI Error: The serve command requires to be run in an Angular project, but a project definition could not be found
When running the terminal commands ng server or ng serve --live-reload=true, I'm getting this issue:
The serve command requires to be run in an Angular project, but a
project definition could not ...
161
votes
6
answers
50k
views
Angular 6 - Why use @ngrx/store rather than service injection
I am recently learning Angular 6 with @ngrx/store while one of the tutorial is to use @ngrx/store for state management, however I don't understand the benefit of using @ngrx/store behind the scene.
...
143
votes
7
answers
160k
views
How to change page title with routing in Angular application?
Is there any npm module/ other way like React-Helmet that allows us to change page title as we route through our Angular application?
PS: I am using Angular 5.
140
votes
23
answers
245k
views
NullInjectorError: No provider for MatDialogRef
I can't inject MatDialogRef as it described in documentation: https://material.angular.io/components/dialog/overview
When i'm trying to do it i'v got error:
ERROR Error: StaticInjectorError[...
124
votes
9
answers
258k
views
Read response headers from API response - Angular 5 + TypeScript
I'm triggering a HTTP request and I'm getting a valid response from it. The response also has a header X-Token that I wish to read. I'm trying the below code to read the headers, however, I get null ...
120
votes
8
answers
534k
views
How to add CORS request in header in Angular 5
I have added the CORS in header but I am still getting the CORS issue in my request. What is the correct way to add and handle CORS and other requests in the headers?
Here is service file code:
...
113
votes
26
answers
408k
views
Error: Schema validation failed with the following errors: Data path "" should NOT have additional properties(project)
After migrating application from angular 5 to 6, on running ng serve the following errors pop up.
Schema validation failed with the following errors:
Data path "" should NOT have additional ...
104
votes
6
answers
296k
views
How to add icon to mat-icon-button
I am using Angular with Material
<button mat-icon-button><mat-icon svgIcon="thumb-up"></mat-icon>Start Recording</button>
I am trying to add an icon to button, but I can't ...
99
votes
3
answers
24k
views
Angular Service Worker - Failed to load resource: the server responded with a status of 504 (Gateway Timeout)
I am using the Angular-CLI 1.6.6 and @angular/service-worker 5.2.5 in our Angular 5.2.5 app. Everything works fine on the local lite-server, as well as on the production server, except for one error ...
97
votes
9
answers
286k
views
Angular 5 Button Submit On Enter Key Press
I have an Angular 5 form application using all the usual models but on the forms I want the form to submit without having to physically click on the 'Submit' button.
I know it's normally as easy as ...
90
votes
14
answers
126k
views
Angular 5: "No provider for ControlContainer"
I have a little web app with Angular 5 and out of a sudden I am getting this strange error message in my browser console:
ncaught Error: Template parse errors:
No provider for ControlContainer ("
...
82
votes
6
answers
77k
views
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/...
80
votes
3
answers
253k
views
Angular 5 Reactive Forms - Radio Button Group
I have 2 radio buttons, I'm using reactive forms and I have added the form controls within my component. The issue I am facing is that the name attribute has to be the same as the formControlName. ...
77
votes
2
answers
240k
views
How to do a timer in Angular 5 [closed]
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 ...
75
votes
10
answers
140k
views
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.
68
votes
9
answers
92k
views
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.
<mat-button-toggle-group #group="matButtonToggleGroup">
<mat-button-toggle value="Heritage">
<...
66
votes
8
answers
301k
views
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 ...
64
votes
6
answers
156k
views
Read a file and parse its content
I have file upload control which holds the selected file as below,
<div class="Block">
<label id="lbl">File </label>
<input #fileInput type='file'/>
</div>
I have a ...
64
votes
9
answers
133k
views
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 ...
63
votes
5
answers
85k
views
Problems with flask and bad request
I was programming myself a pretty nice api to get some json data from my gameserver to my webspace using json,
but everytime i am sending a request using angular i am getting this:
127.0.0.1 - - [20/...
63
votes
8
answers
115k
views
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 ...
63
votes
6
answers
73k
views
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 ...
61
votes
4
answers
91k
views
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 -> ...
59
votes
3
answers
146k
views
Angular 5, NullInjectorError: No provider for Service
Hello im trying to implement firestore into my web application, when i add the service to contructor the error:
NullInjectorError: No provider for TesteventService!
I'm using Angular 5, angularfire2/...
58
votes
7
answers
62k
views
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 {
...
55
votes
6
answers
141k
views
How to reload or refresh only child component in Angular 8
I have two components, One parent and Other Child.
HTML Part
<div>
<div class="row col-md-12">
<div class="col-md-4">
<!-- Some HTML Code of Parent component over ...
55
votes
2
answers
48k
views
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 ...
55
votes
5
answers
72k
views
angular 5 template forms detect change of form validity status
are reactive forms the way to go in order to have a component that can listen for changes in the validity status of the form it contains and execute some compoment's methods?
It is easy to disable ...
55
votes
1
answer
11k
views
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 ...
54
votes
6
answers
107k
views
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 ...
51
votes
7
answers
90k
views
Set value of <mat-select> programmatically
I'm trying to set the value of 2 fields <input matInput> and <mat-select> programmatically. For text input everything works as expected however for the <mat-select> on the view this ...
51
votes
4
answers
74k
views
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 ...
50
votes
8
answers
77k
views
No provider for ControlContainer - Angular 5
I am converting a purchased, third-party template into an Angular 5 app, and just ran into an error. I am very new to Angular 5 (I know AngularJS well however) and don't understand what it's trying to ...
50
votes
7
answers
87k
views
How to create a url string with query parameters from an object in Angular 5+?
I am trying to create a URL from an object in an Angular 5 SPA. My code looks like the following:
import { UrlTree, UrlSegmentGroup, DefaultUrlSerializer, UrlSegment } from "@angular/router";
const ...
50
votes
4
answers
48k
views
How can I check which version of Angular from browser?
I'm trying to buy a angular 5 template online so I just want to confirm for angular version. I have check This question of Angular :-
How can I check which version of Angular I'm using?
But ...
49
votes
4
answers
132k
views
angular router navigate then reload
So I want to reload the app after navigating to a specific route ..
I use router.navigate to navigate to certain route based on user role and that works fine but I have to reload the page after ...
48
votes
2
answers
156k
views
How to call JavaScript functions from Typescript in Angular 5?
I'm working on PDF Viewer development in Angular 5. I'm done with writing HTML code for the UI part. Now I've JavaScript files that provide functionality for the UI elements. As Angular 5 supports ...
48
votes
5
answers
30k
views
CommonModule vs BrowserModule in angular
I am pretty new to the world of Angular. What is the difference between CommonModule vs BrowserModule and why one should be preferred over the other?
47
votes
3
answers
30k
views
Angular 5 internationalization
I'm building an application using the latest Angular5 and what I need is for a user to be able to switch languages. I've never had to implement this in an Angular2+ (actually I'm using Angular5).
I ...
46
votes
3
answers
23k
views
Receive AccessDenied when trying to access a reload or refresh or one in new tab in angular 5
For a while, I was simply storing the contents of my website in a s3 bucket and could access all pages via the full url just fine. I wanted to make my website more secure by adding an SSL so I created ...
46
votes
11
answers
136k
views
How can I get all the rows of ag-grid?
ag-grid provides a way to get selected rows using api.getSelectedRows() function. And provides a way to set all rows using api.setRowData([]) function.
I'm looking for something getAllRows() to return ...
46
votes
5
answers
101k
views
How to listen for value changes from class property TypeScript - Angular
In AngularJS, we can listen variable change using $watch, $digest... which is no longer possible with the new versions of Angular (5, 6).
In Angular, this behaviour is now part of the component ...
45
votes
2
answers
121k
views
Catch error in combined pipe of pipeable rxjs operators
We've just upgraded one of our applications to Angular 5, and started to transition into lettable operators as introduced in rxjs v5.5.
Because of this, we have rewritten our observable pipelines to ...
44
votes
9
answers
168k
views
Uncaught (in promise): Error: StaticInjectorError(AppModule)[options]
I have a strange error. Usually (I did my googling), in this case of errors Angular specifies in square brackets which exactly module/service/provider/etc caused the problem. However here, it says ...
43
votes
8
answers
87k
views
How to set color of toggle buttons
I have group of toggle buttons. They are very light and disappear in the background on poor monitors with a high brightness level.
How can I properly style them? I would prefer to assign them the ...
41
votes
1
answer
63k
views
Use process.env in Angular 5 environment
I try to build an Angular 5 application with the standard ng build --prod command, and I want to set the basic API-Url in the environment.prod.ts to a value dependent on my process.env variables.
...
40
votes
5
answers
81k
views
Angular material Paginator is not working
I am trying to add Angular Material Paginator on my app.
MatPaginatorModule added in module.
<mat-paginator #paginator
[length]="100"
[pageSize]="10"
...