Angular Flashcards
is a container for a group of related components. Every Angular app has at least one of these called App module
Module
are the main building block for Angular applications. Each one of these consists of: An HTML template that declares what renders on the page. A Typescript class that defines behavior. A CSS selector that defines how the (blank) is used in a template.
Components
A blank is one of the properties of the object that we use along with the component configuration. A blank is used to identify each component uniquely into the component tree, and it also defines how the current component is represented in the HTML DOM
Selector
A blank is a blueprint for creating an object, we call that created object an instance of a class, or a class instance or just instance for short. We instantiate a blank by using the new keyword and when that happens JavaScript calls the constructor function.
Class
Blank in Angular is put into use to inject dependencies into the component class. It creates a new instance of the class when the compiler calls ‘new MyClass ()’. While calling ‘new MyClass()’, it is vital that the exact match of the parameter passes the Angular component blank of the class.
Constructor
To use ngOnInit in Angular, it is required to import into the component class in this way – import {Component, OnInit} from ‘@angular/core’. Though implementing ngOnInit for every component is not essential, it is a good practice that further heads towards the smooth functioning of the platform. Angular ngOnInit is created by Angular itself. Angular also renders and checks the changes in its data bounded properties. It is interesting to note that Angular destroys the component before removing it from DOM. ngOnInit in Angular can be hooked to components and directives. Defining the ngOnInit Angular in the class helps Angular runtime to know that is the right time to call the method. The major benefit of this approach is that it adds specific initialization logic near the class lifecycle.
ngOnInit
In Angular, a blank is a chunk of HTML. Use special syntax within a template to build on many of Angular’s features.
Template
Dependencies are services or objects that a class needs to perform its function. Dependency injection, or DI, is a design pattern in which a class requests dependencies from external sources rather than creating them.
Angular’s DI framework provides dependencies to a class upon instantiation. You can use Angular DI to increase flexibility and modularity in your applications.
Dependency injection in Angular
They are instructions in the DOM. They are classes that add additional behavior to elements in your Angular applications. With Angular’s built-in directives, you can manage forms, lists, styles, and what users see.
Directives
Components—directives with a template. This type of directive is the most common directive type.
Attribute directives—directives that change the appearance or behavior of an element, component, or another directive.
Structural directives—directives that change the DOM layout by adding and removing DOM elements.
The different types of Angular directives are as follows:
Decorators are functions that are invoked with a prefixed @ symbol, and immediately followed by a class , parameter, method or property. The decorator function is supplied information about the class , parameter or method, and the decorator function returns something in its place, or manipulates its target in some way.
Decorators
Class decorators, e.g. @Component and @NgModule.
Property decorators for properties inside classes, e.g. @Input and @Output.
Method decorators for methods inside classes, e.g. @HostListener.
Parameter decorators for parameters inside class constructors, e.g. @Inject.
What are types of decorators in Angular?
There are four main types:
Property binding in Angular helps you set values for properties of HTML elements or directives. Use property binding to do things such as toggle button functionality, set paths programmatically, and share values between components.
Property binding
Event binding lets you listen for and respond to user actions such as keystrokes, mouse movements, clicks, and touches.
Event binding
Is like a reserved variable name that you can use in the template when using event binding. It is the data emitted with said event. It gives us access to event data it allows you to fetch event data. Allows you to grab any data an event passes to us
($event)
It will trigger on the input event and update the value of the server name in our component automatically.
It will also update the value of the input element if we change the value of server name somewhere else
[(@ngModel)]
What are the four form of data binding
Event Binding, String Interpolation, Property Binding, and Two Way Binding.
When building your applications and creating logic, there are times when you want to make comparisons between two or more things. They can be abstract things; they can be items in a list or array or even an object. Angular provides directives to handle these situations called conditionals. So, there is ngIf for times when you want to check for a true or false value, and there is ngFor mostly for a list of items either in an object or an array.
Conditionals
is an Angular directive from the router library that is used to insert the component matched by routes to be displayed on the screen.
Router-Outlet
is a directive which binds input, select and textarea, and stores the required user value in a variable and we can use that variable whenever we require that value. It also is used during validations in a form. We can use blank with: input. text.
ngModel
We’ll be learning about the @Input() decorator. … Using the @Input() decorator we can instruct the Angular framework that a property in our directive’s class is an input property, and as such, the value of that property can be set via an input binding on the host element.
What is input directive in Angular?
Input data into a Directive
The child component uses the @Output() property to raise an event to notify the parent of the change. To raise an event, an @Output() must have the type of blank , which is a class in @angular/core that you use to emit custom events.
What is the use of EventEmitter in angular?
Getting the input at the point and time that I click the button. You use blank
A blank can be placed on any html element. You can only use a local reference in your template/ or html page
Local Reference
Getting access to local reference or any element directly from our typescript code. This works before you call a method.
@Viewchild
{{ message }}
Well be back soon!
Sorry for the inconvenience. Were performing some maintenance at the moment.
— Ion Solar Dev Team
Current customer: {{ currentCustomer }}
Go to Settings, and scroll down to the list of apps, tap on FieldPro.
Give permissions to Photos, Microphone, and Camera.", ['OK']); } else { this.createAlert(null, "FieldPro needs permissions to work.
Go to Settings -> Apps -> Field Pro.
Give permissions to Files and Camera.", ['OK']); } }); } convertToJpg(filePath) { return new Promise((resolve, reject) => { window['resolveLocalFileSystemURL'](filePath, (fileEntry) => { fileEntry.file((file) => { const reader = new FileReader(); reader.onloadend = () => { const imgBlob = new Blob([reader.result], { type: 'image/jpeg' }); const newFilePath = this.file.cacheDirectory + 'converted_' + Date.now() + '.jpg'; this.writeFile(newFilePath, imgBlob).then(() => { resolve(newFilePath); }).catch((err) => { reject(err); }); }; reader.onerror = (err) => { reject(err); }; reader.readAsArrayBuffer(file); }, (err) => { reject(err); }); }, (err) => { reject(err); }); }); } writeFile(filePath, fileBlob) { return new Promise
Go to Settings, and scroll down to the list of apps, tap on FieldPro.
Give permissions to Photos, Microphone, and Camera.", ['OK']); } else { this.createAlert(null, "FieldPro needs permissions to work.
Go to Settings -> Apps -> Field Pro.
Give permissions to Files and Camera.", ['OK']); } }); } b64toBlob(b64Data: string, contentType: string): Blob { const byteCharacters = atob(b64Data); const byteArrays = []; for (let offset = 0; offset < byteCharacters.length; offset += 512) { const slice = byteCharacters.slice(offset, offset + 512); const byteNumbers = new Array(slice.length); for (let i = 0; i < slice.length; i++) { byteNumbers[i] = slice.charCodeAt(i); } const byteArray = new Uint8Array(byteNumbers); byteArrays.push(byteArray); } const blob = new Blob(byteArrays, { type: contentType }); return blob; }