Posts

Showing posts from October, 2023

9. Angular and MongoDBs

Angular and MongoDBs 1.       Angular Application Setup Observe   the   link   http://localhost:4200/welcome   on   which   the   mCart   application   is   running.     2.       Components   and   Modules Create   a   new   component   called   hello   and   render   Hello   Angular   on   the   Page   3.       Elements   of   Template Add   an   event   to   the   hello   component   template   and   when   it   is   clicked,   it   should   change the   courseName.   4.       ngFor Create a courses array and rendering it in the template using ngFor directive in a list format   5.       ngClass Ap...

MongoDB QnAs for Vivavoce

  What is MongoDB, and why is it called a NoSQL database? MongoDB is a document-oriented NoSQL database that stores data in JSON-like documents. It is called NoSQL because it does not use traditional SQL (Structured Query Language) for querying data. What is a document in MongoDB? A document in MongoDB is a JSON-like object that contains key-value pairs and is the basic unit of data storage. Explain the structure of a MongoDB document. A MongoDB document consists of fields, which are key-value pairs, and it can have nested documents and arrays. What is a collection in MongoDB? A collection in MongoDB is a group of MongoDB documents. It is similar to a table in a relational database. How do you insert a document into a MongoDB collection? You can insert a document into a collection using the insertOne() or insertMany() method. Explain the concept of ObjectId in MongoDB. ObjectId is a 12-byte identifier that is unique within a collection and is automatically generated for each docu...

8. Services Basics

  Step1: Creating Angular Service The angular service is composed of three things. You need to create an  export  class and you need to decorate that class with  @Injectable  decorator and you need to import the Injectable decorator from the  angular core  library. The syntax to create angular service is given below. Let say you want to create an angular service for fetching the student details and this student details is going to be used by many components. So, open terminal and type  ng generate service Student  and press enter as shown below. ng generate service student // student.service.ts import { Injectable } from '@angular/core'; import { Observable, of } from 'rxjs'; @Injectable({   providedIn: 'root', // This ensures that the service is a singleton and can be injected throughout the app. }) export class StudentService {   private students: Student[] = [     { id: 1, name: 'John', grade: 'A' },     { id:...