Angular and TypeScript Flashcards
What is Typescript?
- Typescript is a superset of javascript which primarily provides the option of static typing, classes, and interfaces.
- Typescript is a transpiled language that is open source.
- Typescript is compiled into javascript to be served on a webpage
- Typescript adds a lot of benefits to what javascript is while still being familiar to javascript users
Is Typescript Loosely or Strongly Typed?
Strongly typed
What does the “let” keyword mean?
Let is similar to var in some respects but let forces local scoping that var can cause problems with.
What does the Arrow Function (=>) do?
- Defines a lambda function.
- Don’t need to type “function”
- Lexically captures the meaning of this.
- Lexically captures the meaning of arguments.
Compiling vs Transpiling?
- Compiling is when source code is converted into machine code.
- Transpiling is a special kind of compiling where instead of being converted into machine code it’s compiled into another language.
What is Angular?
- Angular is a framework built on top of typescript using declarative templates, dependency injection, end to end tooling, and integrated best practices to speed up the development process.
- Angular defines components and uses dependency injection to carry out DOM manipulation for you.
What does it mean to be a Single Page Application
- A single page application (SPA) is a web application or web site that interacts with the user dynamically by rewriting the current page rather than loading a whole new page from a server.
- Interaction with the single page application often involves dynamic communication with the web server behind the scenes.
What is a Webpack?
A Webpack is a module bundler. Takes care of bundling your application for deployment alongside a separate task runner
What is minification?
- The process of removing unnecessary or redundant data without affecting how the resources is processed by the browser.
- Example would be removing of white space, comments, unused code, shorter variable and function names and so on.
- Used to compress source code files for deployment.
What is a module?
- In angular a module is a mechanism to group components, directives, pipes, and services that are related, in such a way that can be combined with other modules to create an application.
- Modules can be easily imported and exported for use.
What are components?
- Components are the most basic building block of a UI in an angular application.
- Everything in angular components and the application is represented as a tree of these components.
What are decorators?
- The whole purpose of the decorator is to store metadata about a class, method, or property.
- The component decorator tells angular that a component is a component and then it knows what it needs to do with it.
- It’s more of an identifier than anything which sounds simple but it’s very important so that angular can differentiate components and their purposes.
What are some common decorators?
@Component @NgModule @Input @Output @Inject
What is a directive?
- Directives allow you to attach behavior to elements in the DOM.
- Directives are identified with the @Directive decorator.
- Directives must be present in the declarations field of your NgModule for it to be usable by another directive, component, or application.
What is a Structural Directive?
- Must be annotated with the @Directive decorator
- Structural directives are responsible for HTML layout. - - They shape or reshape the DOM’s structure by adding, removing, or manipulating elements.
- Structural directives are how Angular does DOM manipulation.
- Actions of Structural directives also affect children elements.
- Examples are:
- NgIf
- NgFor
- NgSwitch
What is an Attribute Directive?
- Attribute Directives change the appearance or behavior of a DOM element, component, or another directive.
- Attribute directives are used as attributes of elements
- Must be annotated with the @Directive decorator
- A good example is the NgStyle directive which is built-in to angular.
What is ngModel?
- NgModel is an Angular Directive
- Creates a FormControl instance from a domain model and binds it to a form control element.
- The FormControl instance will track the value, user interaction, and validation status of the control and keep the view synced to the model.
- Can be used by itself or as part of a larger form, if so it will also register itself with the form as a child control.
- Often used to achieve two-way databinding.
What is a Dependency Injection?
Dependency Injection is a form of Inversion of Control, where you give up control to an outside entity. The outside entity provides you the instance of the dependency that you need, so that you don’t worry about the implementation of your resource, but instead focus on the business logic you are constructing. Dependency Injection is beneficial because it keeps your classes loosely coupled and isolates test cases.