advanced-co-angular-questions
advanced-co-angular-questions
observables promises
Create : Create:
const obs = new const promise = new Promise(() =>
Observable((observer) => { {
observer.next(10); resolve(10);
}) ; });
Transform: Transform:
Obs.pipe(map(value) => value * 2); promise.then((value) => value *
2);
Subscribe: Subscribe:
const sub = obs.subscribe((value)
=> {
promise.then((value) => {
console.log(value)
console.log(value)
});
});
Unsubscribe: Unsubscribe:
sub.unsubscribe();
Can’t unsubscribe
What is multicasting?
Using the HttpClient module, you can communicate with a backend service and
fetch data.
Multitasking allows you to broadcast this fetched data to multiple subscribers in
one execution.
How will you set, get, and clear cookies in Angular?
ngOnInit is a life cycle hook called by Angular to indicate that the Angular is done
creating the component.
The Ivy compiler: The default use of the Ivy compiler is the most important feature of
Angular 9, Ivy is what actually designed to solve the major problems of Angular i.e the
It's essential to keep in mind that Angular continues to evolve with each new
release, and the benefits of a specific version depend on your project's needs
and requirements. When considering an upgrade, it's advisable to consult the
official Angular release notes and documentation for the most accurate and
up-to-date information on the improvements and changes in each version.
Please note that Angular's development continues, and newer versions may
have introduced further improvements and optimizations. Therefore, it's a
good practice to consult the official Angular release notes and documentation
for the latest information on ngcc and its performance enhancements in the
most recent versions of Angular.
The Plain Old JavaScript Objects (POJO) Model is used by Angular to make the
code structure portable and independent. This enables us to avoid introducing
complicated functions or methods to the programme. It also eliminates the need
for third-party frameworks or plugins.
Because POJO needs less coding, apps produced with Angular load quickly and
give outstanding user accessibility. One of the best Angular benefits is that the
model allows us to keep the scripts clean, making the framework goal-oriented.
The Angular CLI tool allows developers to establish basic projects, perform tests,
and add new functionalities in a single project while keeping the entire team
informed. Angular’s style guide is frequently appreciated by the developers. This
makes team communication more comfortable and is less likely to be
misconstrued.
Thanks to the framework’s extensive ecosystem, which has generously provided
the developer community with the power of dependency injection and other
resources.
Developers are more confident in building a clean user interface with seamless
business logic as the framework separates business logic from UI components.
This is because of the controller’s rapid communication between the model and
the view component. As a result, data is shown as rapidly as feasible and this
marks as one of the best angular benefits.
Ivy renderer strives for exceptional code debugging and a user-friendly app
experience. It makes the framework more accessible and sets a good example
by lowering file sizes while still maintaining the framework as a feature-rich
platform. It wasn’t in its final shape when it was unveiled at NG-CONF 2018,
however the recent versions of Angular presently offers the best of it. With the
introduction of Angular 9, the contemporary Angular engine has be in its full
form.
The numerous advantages of Angular has made the platform popular among
developers and engineers since its inception. Angular is simple to incorporate for
those who want to get the most out of it, with a wealth of resources such as
study materials, reference articles, FAQs, and much more.
5. Features of angular 10?
1. Language Service
3. Compiler Update
Once this flag is enabled, it initializes the new project with a couple
of new settings that improve maintainability, assist in catching bugs
well ahead in time, and permit the CLI to perform advanced
optimizations on your app. Enabling this flag configures the app as
side-effect free to ensure more advanced tree-shaking.
5. Ngcc
By using this option, one can catalyze the process in places with a
number of dependencies installed with relatively small numbers of
entry points that are actually imported into the application. This
particular feature helps manifest and reduce the file size of the
entry-point.
The base path of the package and entry points need not be stored in
the file, and hence Storing unnecessary empty arrays can be
avoided. In the previous versions, ngcc seemed to parse the files of
the entry point in order to compute dependencies. This would take a
lot of time for large node modules.
6. Performance Improvements
7. Service Workers
Typescript helps save the files with its rich editing functionality
across editors. With Typescript 3.9 the team has worked on
performance, polish, and stability. Apart from error-checking, this
version powers things like completions, quick fixes and speeding up
the compiler and editing experience.
9. Localization
One of the best features of Angular 10 is that the latest angular version
supports for merging of multiple translation documents which could only
load one file in the previous versions.
10. Router
The CanLoad guard now can go back Urltree in angular version 10. A
CanLoad guard returning Urltree cancels the cutting-edge navigation and
helps to redirect. This matches current behavior to the available
CanActivate guards that are also apparently added. This however doesn’t
affect the preloading. Also, any routes with a CanLoad guard won’t be
preloaded, and the guards will not be completed as a part of preloading.
11. Deprecation
Operation Byelog is the first entity where the angular team concentrated
on spending a substantial engineering effort, especially in triage
problems and PRs, before providing a good understanding of the
extensive needs of the group. Hence it can now be confirmed that the
initial target is over!
Though all the new projects since Angular v11 were auto-configured
to the new message ID. Now, with Angular 12 we’ve got the
essential tools to migrate the translations.
Some of the alternative solutions are tried with Cypress, WebDriverIO, and
Test Cafe.
★ Nullish Coalescing
Typescript developers out there might have already been excited
about this particular Angular 12 feature. The fantastic nullish
coalescing operator (??) that enables you to write cleaner code, is now
acceptable in Angular 12 templates. So, instead of this:
Angular Learning
Also, there’s a contributor’s guide that helps the developers improve their
project documentation. More to this, ever since the Angular 11 release,
the community shares useful ways to debug guides and videos.
★ Style Improvements
The best part of Angular 12 features is this amazing thing- they’ve added
support for inline SaaS in styling fields and component decorators. Earlier,
developers could only avail SaaS from external mediums because of the
restriction of the Angular compiler.
You can add the support by using the SCSS or you should add the
following command: “inlineStyleLanguage”: “scss” in your json file.
Talking about the Tailwind CSS, Angular v11.2 had already enabled the
support for styling. Another noteworthy update is that Angular Material
and Angular CDK have adopted the new SaaS module, for which you’ll
have to download saas npm package and switch from node-saas.
The new SaaS API comes with the @use syntax, which makes it more
useful and has meaningful naming conventions. As you update your web
app to Angular 12 features, you will be automatically switched to the new
SaaS API.
It is rightly said “Nothing lasts forever” and now is the time we bid
farewell to Internet Explorer 11. You will find the deprecation message in
the Angular 12 update for Internet Explorer 11 IE11. Until Angular v11, it
was supported, but not continued.
The not-so-good news for IE lovers- your favorite browser IE11 will not be
supported by the new version of Angular – v12.
★ Some more of new Angular 12 features
Here are additional features that when your Angular 12 download is done:
build
The main new features in Angular 13 are TypeScript 4.4 support, version
7.4 of RxJS, router changes, Angular CLI enhancements, testing
improvements, and dynamic components. Many of the Ivy-based features
and optimizations have been expanded to help you and your teams build
excellent apps.
1. Offline Mode: They save a copy of your app on the user's device so that
even if the internet connection is lost, your app can still work.
2. Speed Boost: They make your app faster by storing commonly used
things (like images and scripts) on the user's device, so your app doesn't
have to download them every time.
3. Background Updates: They quietly update your app in the background,
so users always have the latest version without even knowing it.
4. Push Notifications: They enable your app to send pop-up messages to
users, even when the app is closed, like how your phone gets notifications.
Think of service workers as your app's loyal sidekick, ensuring it runs smoothly,
even when the internet is acting up, and giving your users a better experience.
To set up the Angular service worker in your project, use the CLI command ng
add @angular/pwa. It takes care of configuring your application to use service
workers by adding the @angular/service-worker package along with setting up the
necessary support files.
ng build
The CLI project is now set up to use the Angular service worker.
web worker
Web workers are used for running any script in the background threads, without
interfering with the user's interface. So if you have heavy computations on your
user side, you can use web workers to do the heavy tasks while allowing the
browser to give your users a smooth and better experience.
It’s quite easy to create a web worker in Angular. You can use Angular CLI
4. Your app.component.ts will also be modified and the worker will be used here
Now if you run your Angular application using npm start, you can see the above
response in Console.
Server-side rendering
Also for a more detailed look at different techniques and concepts surrounding
SSR, check out this article.
Angular guards:
In Angular, guards are a set of mechanisms that allow you to control the
navigation and access to different parts of your application. They are used to
protect routes, control permissions, and manage the flow of your application
based on certain conditions. Angular provides several types of guards to handle
various scenarios:
Since Angular creates a SPA (Single Page Application), all of its components
are loaded at once. This means that a lot of unnecessary libraries or modules
might be loaded as well.
For a small application this would be okay. But as the application grows the load
time will increase if everything is loaded at once. Lazy loading allows Angular to
load components and modules as and when they're needed.