Setting Up http services in angular

     


Structural Directives Vs Attribute Directives In Angular

     

What are directives in Angular? Directives are instructions in the DOM. Components are directives; however, they have a template. We typically add directives with attribute style. @Directive({ selector: ‘[warningalert]’ }) export class WarningAlertDirective { } Structural Directive *ngIf is a structural directive because it changes the structure of the dom. Attribute Directives ngStyle allows us to dynamically update styles. [ngStyle]=“{backgroundColor:getColor()}” property binding = [] Add A button which says 'Display' Add a paragraph about Wakanda Toggle the displaying of that paragraph with the button created in the first step Log all button clicks in an array and output that array below the paragraph aboveStarting at the 2nd log item, give all future log items a blue background (via ngStyle) and white color (ngClass) Below is the component code:


Understanding Angular Lifecycle Events

     

Angular calls lifecycle hook methods on directives and components as it creates, changes, and destroys them. Angular creates it, renders it, creates and renders its children, checks it when its data-bound properties change, and destroys it before removing it from the DOM. Hook Purpose and Timing ngOnChanges() Respond when Angular (re)sets data-bound input properties. The method receives a SimpleChanges object of current and previous property values.


Understanding what happens during a complex LAMBDA query

     

LAMBDA expressions were introduced in C# 3.0 (.NET 3.5) along with LINQ. The LAMBDA expression is a shorter way of representing anonymous methods using special syntax. For example, the following anonymous method checks if the customers balance is over $1000: Anonymous method in C#: The above anonymous method can be rewritten using the following: Lambda Expression in C#: c => c.Balance > 1000 Below is a more complex LAMBDA expression:


Using Angular CLI To Generate Component

     

Typescript has more features than vanilla JS. eg Types, Classes, Interfaces, etc. A component is just a class. We have to export our class. The naming convention is very important such as AppComponent. We can also create new components using Angular CLI. We can see in the following video that we can use the following: 1. ng generate compononent name 2. ng g c name


Using Dependency Injection To Provide Services In Angular

     

What are services in Angular. Its just another class. Its a central repository to centralize our code and prevent code duplication. Common scenarios are logging functions and accessing data. We can use Dependency Injection to inject our service into the Component. When creating a service, we have to let Angular know about our LoggingService. A service allows us to follow the DRY principle which is Don’t Repeat Yourself. In the Component, we have to use the constructor to inject the service.


What is SOLID

     

S.O.L.I.D is an acronym for the first five object-oriented design(OOD) principles by Robert C. Martin aka Uncle Bob. S - Single-responsiblity principle (SRP) O - Open-closed principle L - Liskov substitution principle I - Interface segregation principle D - Dependency Inversion Principle S.R.P states that “A class should have one and only one reason to change, meaning that a class should have only one job.” Open-closed Principle states that “Objects or entities should be open for extension, but closed for modification.


What is a generic class Dot.NET

     

At its core, a generic class is a special class that allows you to define a class with placeholders for the type of its fields, methods, parameters, etc. Generics replace these placeholders with some specific type at compile time. Generics were first introduced in C# 2.0. A generic class can be defined using angle brackets <>. For example, the following is a simple generic class with a generic member variable, generic method and property.


What is boxing and unboxing in C#

     

C# Type System contains three Types: 1. Value Types 2. Reference Types 3. Pointer Types. C# allows us to convert a Value Type to a Reference Type, and back again to Value Types. The operation of Converting a Value Type to a Reference Type is called Boxing and the reverse operation is called Unboxing. Boxing and UnBoxing are computationally expensive processes. When a value type is boxed, an entirely new object must be allocated and constructed, also the cast required for UnBoxing is also expensive computationally.


What is the difference between Optimistic Concurrency versus Pessimistic Concurrency

     

Optimistic Locking is a way of versioning your record by add either a date, timestamp or hash. If there are multiple users updating that record, the software will know if the record has changed based on the hash. The reason for this is that you have to make sure the version is atomic. This means that the record hasn’t been updated by another user while you were editing the value.