- From Parent to access child component
- @ViewChild()
- Pass Data between child and parent component
Thursday, February 23, 2023
How Access Between Angular
Angular Question
- Type of Data Binding
- One Way Binding
- Interpolation Bnding
- data move in one direction from components (typescript) to HTML
- <p>{{ message }}</p>
- Property Binding
- set properites to HTML elements.
- [value]="user.email" or <img [src]="imageUrl">
- Two Way Binding
- component and view are always in sync
- Changes in user interface to model state.
- Changes in model state reflect to user interface
- <input [(ngModel)]="name">
- Event Binding
- One Way Binding
- for event trigger
- <button (click)="doSomething()">Click me</button>
- How does one share data between components in Angular?
- Parent to child using @Input decorator
- Child to parent using @ViewChild decorator
- Child to parent using @Output and EventEmitter
- Decorators
- Design Pattern & function
- modification to a class, service or filter
- 4 Types
- Class Decorators
- Property Decorators
- Method Decorators
- Parameter Decorators
- Advantages
- MVC architecture
- Modules
- componentes
- directives
- pipe
- services
- Dependency Injection
- component dependent on other components can easily worked around
- Others
- clean and maintainable code
- reusable components
- data binding
- unit testing
- Directives
- attributes allow user write new HTML syntax
- 3 Types
- Component Directives
- Structural Directives
- Attribute Directives
- myHighlist is Directives
- Template
- HTML View
- seperate template file such **.html
- Template Statements
- properties or methods
- (click)='addUser()"
- addUser is template
- Promises and Observables
- Promises
- emit single value at a time
- Execute immediately after creation and not cancellable
- Push Errors to child Promises
- Observables
- execute when subscribe()
- emit Mutiple value over a period of time
- perform forEach, filter and retry
- Deliver errors to subscribers.
- When unsubsribe() is called, listener stop receive further values.
Observable Promise Declarative: Computation does not start until subscription so that they can be run whenever you need the result Execute immediately on creation Provide multiple values over time Provide only one Subscribe method is used for error handling which makes centralized and predictable error handling Push errors to the child promises Provides chaining and subscription to handle complex applications Uses only .then() clause - Difference AngularJS and Angular
AngularJS Angular It is based on MVC architecture This is based on Service/Controller It uses JavaScript to build the application Uses TypeScript to build the application Based on controllers concept This is a component based UI approach No support for mobile platforms Fully supports mobile platforms Difficult to build SEO friendly application Ease to build SEO friendly
Sunday, February 19, 2023
Dependency Injection 2
What is Dependency Injection
- Produce a loosely coupled code
- Any change in the class without affecting other object.
- Type of DI
- Constructor Injection
- parameter to inject dependencies in a class
- One parameterized constructor but no default constructor and you need to pass specified values to the constructor
- Setter Injection
- through properties of a class
- Interface-based injection
- through method
- Advantage
- Maintainability
- maintain code structure, single principle
- Flexibility
- loosely coupled code, flexible to use different ways.
- Testability
- easy to do unit testing
- Readability
- Logic in constructor.
Subscribe to:
Posts (Atom)