TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
jude jay
NA
17
1.6k
Send Boolean to WEB API in Angular with checkbox
Feb 18 2021 6:57 PM
Hi,
I have an API i would like to get a subset of the data by setting a boolean on the form, checkbox would be ideal.
The API is the same one returns all the set, but has an extra true or false, works with swagger.
This is Angular 11. Not used any material or bootstrap yet.
Using a service to bring in the data from the API, can get list rendered of all values atm..
The base uRL is just that same with true added.
SO FAR
HTML
<input #sendBulletinCheckBox
id="sendBulletinCheckBox"
type="checkbox"
[checked]="sendBulletin"
(change)="onSendBulletinChanged(sendBulletinCheckBox.checked)" />
TS Service function to get API data
refreshList() {
return this.httpClient.get<{ [key: string]: CustomerDetails }>(this.baseURL ,
{
headers: new HttpHeaders({ 'Custom-Header': 'Hello'}),
responseType:'json'
}
)
.pipe(
map(responseData =>
{
const contacts: CustomerDetails[]=[];
for (const key in responseData){
if (responseData.hasOwnProperty(key)){
contacts.push({ ...responseData[key], Id: key});
}
}
return contacts;
}),
catchError(errorRes => {
return throwError(errorRes);
})
);
Reply
Answers (
1
)
ng auto-complete with from array
Download file at given path other than download folder in angular