Answered by:
How to display count of records on tables using angular 7 ?

Question
-
User696604810 posted
problem
How to display count of records on tables using angular 7 ?
I work on SQL server 2012 and asp.net core 2.2
I make web API on .net core 2.2 return count of records on table
meaning function API return only one value as integer
my questionHow to display count of items on angular 7 ?
localhost:8089/api/countitems
on apiservice.ts
How to receive count from link below
ocalhost:8089/api/countitems
on itemsComponent.ts
How to call service here and receive count
itemsComponent.html
how to display count here on div or labelSunday, February 23, 2020 8:14 AM
Answers
-
User696604810 posted
can you give answer to my question please
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, February 25, 2020 11:05 PM -
User-474980206 posted
a trival react example. the ajax should be the same in angular (except the binding). use angular template
import React, { useState, useEffect } from 'react'; const URL = 'http://www.example.json'; // define count state const [count, setCount] = useState(0); // define ajax caller async function fetchCount() { const count = await fetch(url).json(); setCount(count); } // define application const App = () => { useEffect(() => { fetchCount(); }) return <div> {count} </div>; }
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, March 5, 2020 5:02 PM
All replies
-
User-474980206 posted
First core 2.2 is out of support. You should fall back to 2.1 or upgrade to 3.1. Also Sqlserver 2012 is out of support.
second it looks like you are asking basic angular questions. How to call an api and how to bind the response. You should take an angular training course or run thru some tutorials, so you are asking angular to asp.net questions, not how do I basic angular coding.
Tuesday, February 25, 2020 7:07 PM -
User696604810 posted
can you give answer to my question please
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, February 25, 2020 11:05 PM -
User-474980206 posted
a trival react example. the ajax should be the same in angular (except the binding). use angular template
import React, { useState, useEffect } from 'react'; const URL = 'http://www.example.json'; // define count state const [count, setCount] = useState(0); // define ajax caller async function fetchCount() { const count = await fetch(url).json(); setCount(count); } // define application const App = () => { useEffect(() => { fetchCount(); }) return <div> {count} </div>; }
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, March 5, 2020 5:02 PM