Guided Exercise - Angular App with API Data Fetching - Magical Users #159
akash-coded
started this conversation in
Tasks
Replies: 2 comments 1 reply
-
OUTPUT |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment





Uh oh!
There was an error while loading. Please reload this page.
-
Let's recreate the "Magical Users" app in Angular. As we go along, I'll explain each Angular concept in-depth, and contrast it with the React approach from the given exercise.
Creating "Magical Users" App in Angular
Step 1: Setup
cd magical-usersOpen your browser and go to
http://localhost:4200to see the default Angular app running.Step 2: Install Axios
HttpClientmodule for HTTP requests. So, we'll set that up.First, open
src/app/app.module.tsand importHttpClientModulefrom@angular/common/http. AddHttpClientModuleto theimportsarray.Step 3: Clear the default project and Fetch Users
src/App.jsand fetched users using Axios.Open
src/app/app.component.ts:Then, in
src/app/app.component.html:Step 4: Create UserCard component
UserCard.js.In
src/app/user-card/user-card.component.ts:In
src/app/user-card/user-card.component.html:Step 5: Add some styles
The styling remains largely the same. Add the provided styles to
src/styles.css.Step 6: Run the app
With
ng serverunning, visithttp://localhost:4200. You should see the app functioning similarly to the React version.Angular Concepts & Contrasts with React:
Angular CLI vs. Create React App:
Angular Components vs. React Components:
HttpClient vs. Axios:
HttpClientmodule.State & Lifecycle:
useStateand lifecycle methods/hooks likeuseEffect.ngOnInit(similar tocomponentDidMount) and properties for state.Input & Props:
@Input()decorator to receive data from parent components.Event Handling:
onClick).(click)).Conditional Rendering:
&&or ternary operators).*ngIf.Styling:
By the end of this exercise, React freshers should grasp Angular's architecture, data flow, component structure, and HTTP mechanisms. Contrasting Angular and React provides a solid understanding, facilitating the transition between frameworks.
Beta Was this translation helpful? Give feedback.
All reactions