This document discusses Angular directives, including built-in and custom directives. It describes the three types of built-in directives - component directives, structural directives, and attribute directives. It provides examples of common built-in directives like ngIf, ngFor, ngSwitch, ngModel, ngStyle, and ngClass. It also explains how to create a custom attribute directive to dynamically style an element.
A simple tutorial for understanding the basics of angular JS. Very useful for the beginners. Also useful for the quick revision. Very attractive design for the tutorial of angular js.
The document discusses various methods for sharing data between Angular components, including:
1) Parent to child components using @Input to pass data via templates.
2) Child to parent using @ViewChild and AfterViewInit lifecycle hook to access child component properties.
3) Child to parent using @Output and event emitters to emit data on user events like button clicks.
4) Between unrelated components using a shared service with RxJs Subjects to share stream of data between all components accessing the service.
Presentation about new Angular 9.
It gives introduction about angular framework.
Provides information about why we use angular,
additional features and fixes from old versions. It will clearly explain how to create a new angular project and how to use angular commands and their usages.
It will also explain about the key components like angular architecture, routing, dependency injection etc.,
Angular - Chapter 4 - Data and Event HandlingWebStackAcademy
The document provides information about Angular data binding and event handling. It discusses how interpolation can be used to connect data from a component class to its template. It also explains how property binding and event binding allow two-way communication between the component class and template. Finally, it introduces ngModel for setting up two-way data binding between an input element and a property.
JavaScript variables hold values and are declared with var. Variable names are case sensitive and must begin with a letter or underscore. Variables can hold numbers, strings, Booleans, objects, and null values. Arrays are objects that hold multiple values in a single variable. Functions are blocks of code that perform tasks and are executed by events or calls. Objects store related data and functions to represent self-contained entities.
This document discusses data binding in AngularJS. It explains what data binding is, the difference between one-time and two-way binding, and how data binding works through dirty checking. Data binding connects the UI and business logic by allowing changes in the model to be reflected in the view and vice versa. One-time binding only updates the view once from the controller value, reducing the number of watchers and improving performance compared to two-way binding. The document also provides examples of data binding and takes questions.
Angular is a TypeScript-based framework for building single-page web applications. Some key points:
- Angular 14 is the latest version, released in June 2022. It introduced features like standalone components and typed forms.
- Angular provides advantages like cross-platform support, improved speed/performance, and support for unit testing.
- The Angular CLI is used to initialize, develop, and maintain Angular apps from the command line. Commands include ng new to create a new app and ng help to view available commands.
AngularJS is a JavaScript framework for building dynamic web applications. It augments HTML with custom attributes and directives to bind data and behaviors to the DOM. Key features include two-way data binding, reusable components, dependency injection, routing, and templating. AngularJS uses an MVC or MVVM pattern, with scopes providing the view model. The framework enhances HTML, encourages test-driven development, and makes single page apps possible.
This document provides an overview of Angular, including:
- Angular is a JavaScript framework used to build client-side applications with HTML. Code is written in TypeScript which compiles to JavaScript.
- Angular enhances HTML with directives, data binding, and dependency injection. It follows an MVC architecture internally.
- Components are the basic building blocks of Angular applications. Modules contain components and services. Services contain reusable business logic.
- The document discusses Angular concepts like modules, components, data binding, services, routing and forms. It provides examples of creating a sample login/welcome application in Angular.
AngularJS is an open source JavaScript framework maintained by Google that extends HTML with new elements and attributes. It uses a Model-View-Whatever architecture to develop single-page applications. Key AngularJS components include directives, expressions, and controllers that allow two-way data binding between models and views.
This document provides an introduction to JavaScript, covering basic concepts like data types, variables, operators, conditionals, loops, functions, arrays, and objects. It explains that JavaScript is an interpreted language that allows dynamic and interactive functionality on websites. Key points are demonstrated through examples, like using alert to output "Hello World" and basic math operations with variables.
This document provides an overview of Angular's template-driven and model-driven forms. It describes the key directives, classes, and interfaces used for building forms in Angular. It explains how to add validation, track form state, create custom validators, and tie forms to components and templates. The document also demonstrates how to set up two-way data binding between forms and models using directives like ngModel, ngFormControl, and ngForm.
A directive is a custom HTML element that is used to extend the power of HTML. Angular 2 has the following directives that get called as part of the BrowserModule module.
ngif
ngFor
If you view the app.module.ts file, you will see the following code and the BrowserModule module defined. By defining this module, you will have access to the 2 directives.
- Angular modules help organize an application into blocks of related functionality. Modules declare components, directives, pipes and services that belong to that module.
- There are different types of modules like root modules, feature modules, and shared modules. The root module launches the app. Feature modules extend functionality. Shared modules contain reusable constructs.
- Modules can import and export specific constructs to make them available to other modules. Services declared in a module are singletons app-wide unless the module is lazy loaded. Core modules contain global services imported by the root module only.
Angular is a development platform for building mobile and desktop web applications using TypeScript/JavaScript. It is an update to AngularJS with a focus on mobile and typesafety. Major versions include Angular 1.x, 2.x, 4.x and 5.x. Angular uses components, services and modules to build applications with templates and styles. It is compiled to JavaScript using transpilation and supports AOT and JIT compilation. Common tools used with Angular include the Angular CLI, Webpack and Zone.js.
This document provides an overview of Spring MVC including:
- Spring MVC is a web framework built on the Servlet API that uses the MVC pattern. It features a DispatcherServlet that handles requests and delegates to controllers.
- The request processing workflow in Spring MVC involves the DispatcherServlet dispatching tasks to controllers, which interact with services and return a view name. The view is then rendered using a ViewResolver.
- Spring MVC applications use a WebApplicationContext containing web-related beans like controllers and mappings, which can override beans in the root context. Configuration can be done via XML or Java-based approaches. Important annotations map requests and bind parameters.
This is the slides I used when I shared my humble insight on Django to the students in University of Taipei in 2016. Please feel free to correct me if there is anything wrong.
This document provides an introduction to Angular, including its history and architecture. Angular is a TypeScript-based front-end framework for building client-side dynamic web applications. It discusses when to use Angular, such as for large complex projects or apps with dynamic content. The document also covers Angular's modules, components, data binding, directives, services and dependency injection.
Introduction to angular with a simple but complete projectJadson Santos
Angular is a framework for building client applications in HTML, CSS and TypeScript. It provides best practices like modularity, separation of concerns and testability for client-side development. The document discusses creating an Angular project, generating components, binding data, using directives, communicating with backend services, routing between components and building for production. Key steps include generating components, services and modules, binding data, calling REST APIs, defining routes and building the app.
AngularJs Workshop SDP December 28th 2014Ran Wahle
This document provides an overview and agenda for a training on AngularJS. It introduces key concepts in AngularJS like modules, dependency injection, data binding with controllers and scopes, services, filters, directives, forms, and routing. Code examples are provided to demonstrate creating modules, controllers, services, binding data between the view and model, and using built-in and custom directives. The training will cover building AngularJS applications with a focus on best practices.
AngularJS is an open-source JavaScript framework for building dynamic web applications. It uses HTML as the template language and allows extending HTML vocabulary for the application. The key concepts covered in the document include modules and dependency injection, data binding using controllers and scopes, services, filters, form validation, directives, and routing. Various AngularJS features like modules, controllers, services, directives etc. are demonstrated via code examples. The document provides an introduction to core AngularJS concepts through explanations, code samples and a demo.
The document discusses how web pages are created using HTML, CSS, and JavaScript. It explains the Document Object Model (DOM) and how JavaScript can manipulate the DOM. It then provides an overview of AngularJS including what it is, how it works, and some key concepts like directives, dependency injection, services, and data binding.
Angularjs is a client side javascript framework that adds interactivity to HTML. It allows developers to create dynamic and interactive web applications. Some key features include directives, modules, controllers, expressions and data binding. Directives are HTML annotations that trigger javascript behaviors. Modules group application components. Controllers add application logic and behavior. Expressions display dynamic values in the HTML. Angularjs uses MVC architecture with the view being the DOM, controllers handling logic, and models storing data. It also utilizes dependency injection to manage dependencies between components.
This document provides an overview of key concepts in AngularJS including two-way data binding, directives, modules, controllers, expressions, validation, filters, services, dependency injection, and custom directives and services. It explains how AngularJS uses directives, modules, and controllers to organize code. It also covers core functions like data binding, validation, filters, and dependency injection via the injector.
1. Angular Components:
Component Configuration, Building a Template, Using Constructors, Using External Templates, Angular Routing to Single Page Application (SPA)
2. Data Binding:
Introduction, Interpolation, Property Binding, Attribute Binding, Class Binding, Style Binding, Event Binding, Two-way Binding.
Angular is an open-source JavaScript framework for building mobile and desktop web applications. It uses TypeScript for development and focuses on building single page applications. The key aspects of Angular include components, modules, templates and data binding.
To set up an Angular application, developers must install Node.js, Angular CLI and configure the development environment. The Angular CLI is used to generate components, run tests and deploy applications. Components and modules are fundamental building blocks - components define views and logic, while modules organize an application's components. Data binding in templates connects application data and DOM elements.
The document discusses directives in AngularJS. It begins with an overview of HTML elements, nodes, tags and attributes. It then defines what a directive is - code that enhances HTML elements with additional functionality. Directives are defined using the .directive() method and can customize element behavior. The document covers different types of directives like isolating directive scope for reusability. It provides examples of creating a basic directive that passes data into its template using attributes, and binding to isolate scope properties.
Introduction to Angular js , Angular js PDF , What is angular js ?? angular js pdf explanied. introduction to angular js. angular js online slide presentations. angular js explained pdf introductions
AngularJS 101 - Everything you need to know to get startedStéphane Bégaudeau
In this presentation, you will find everything need to get started with AngularJS.
For more details, have a look at my blog (http://stephanebegaudeau.tumblr.com) or follow me on twitter (@sbegaudeau)
Angular Js Get Started - Complete CourseEPAM Systems
This document provides an introduction and overview of AngularJS, including:
- AngularJS is a JavaScript framework for building dynamic web applications and sites. It allows building applications that run in web browsers using HTML.
- Key AngularJS concepts covered include directives, controllers, modules, services, filters, forms, routing and two-way data binding.
- Examples are provided to demonstrate how to create AngularJS applications, controllers, directives, filters and more.
- Custom directives and services can be created to extend the functionality of AngularJS applications.
The document provides an agenda and overview of key concepts in AngularJS including single page applications, directives, data binding, MVC pattern, modules, routes, factories and services. It discusses downloading and setting up AngularJS, its building blocks like views, controllers and models. It also provides examples of using directives for data binding, iteration, conditional display, and creating custom directives.
Angular is a platform and framework for building client applications in HTML and TypeScript. The main building blocks of an Angular application are modules, components, directives, and services. Modules provide a compilation context and make components and directives available. Components define views and use services. Services provide reusable business logic. Directives add behavior to existing elements.
AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. AngularJS's data binding and dependency injection eliminate much of the code you would otherwise have to write. And it all happens within the browser, making it an ideal partner with any server technology.
Introduction to single page application with angular jsMindfire Solutions
This document summarizes a presentation on AngularJS. It introduces AngularJS as a JavaScript framework for building single-page applications. It covers key AngularJS concepts like modules, controllers, views, directives, routing, services, filters and custom directives. It also provides examples of creating modules, controllers and views, using directives for data binding, implementing routing and dependency injection. The presentation concludes by discussing upcoming topics like custom directives, isolated scopes, services and testing with AngularJS.
Angular directives allow for extending HTML functionality and manipulating the DOM. There are three types of directives: component directives which define reusable UI elements, structural directives which change layout, and attribute directives which alter appearance/behavior. Component directives combine templates, classes, and metadata. Attribute directives like ngStyle and ngClass dynamically set styles/classes. Structural directives like ngFor and ngIf conditionally render elements. Custom directives can also be created to encapsulate reusable logic.
Get rid of controllers in angular 1.5.x start using component directivesMarios Fakiolas
We can now build an AngularJS 1.5.x application by replacing controllers with components. That way we can prepare even better our old applications for their upgrade to Angular 2 and its components ways.
This document provides guidance on structuring real Angular app architecture to keep it simple but powerful. It discusses using modules to bundle controllers, directives, services, etc. It emphasizes making slim controllers and putting business logic in services. Services should not manipulate DOM. Directives are for repeated UI functionality and can manipulate DOM. Templates are used to generate DOM elements. The document provides an example app architecture with common modules and components like services for $http requests, offline syncing, state management, loading indicators, and notifications. Controllers publish instances to templates that bind to the DOM.
Introduction to Data Science, Prerequisites (tidyverse), Import Data (readr), Data Tyding (tidyr),
pivot_longer(), pivot_wider(), separate(), unite(), Data Transformation (dplyr - Grammar of Manipulation): arrange(), filter(),
select(), mutate(), summarise()m
Data Visualization (ggplot - Grammar of Graphics): Column Chart, Stacked Column Graph, Bar Graph, Line Graph, Dual Axis Chart, Area Chart, Pie Chart, Heat Map, Scatter Chart, Bubble Chart
This document provides an introduction and overview of using R for data visualization and analysis. It discusses installing both R and RStudio, basics of R programming including data types, vectors, matrices, data frames and control structures. Descriptive statistical analysis functions are also introduced. The document is intended to teach the fundamentals of the R programming language with a focus on data visualization and analysis.
This document provides an introduction to statistics and data visualization. It discusses key topics including descriptive and inferential statistics, variables and types of data, sampling techniques, organizing and graphing data, measures of central tendency and variation, and random variables. Specifically, it defines statistics as collecting, organizing, summarizing, analyzing and making decisions from data. It also outlines the main differences between descriptive statistics, which describes data, and inferential statistics, which uses samples to make estimations about populations.
1) GIS projects can fail due to poor planning, lack of management support, and poor project management. Key factors include inadequate staffing, funding, and software development processes.
2) A GIS implementation plan is important to reduce mistakes, integrate management of data, computing, staff, and technology. It provides guidelines for an efficient implementation.
3) The GIS planning and implementation process has five phases - planning, requirements analysis, design, acquisition/development, and operations/maintenance. Planning defines the project scope and develops a general plan.
This document discusses spatial analysis and modeling in a geographical information system. It defines spatial analysis as gaining an understanding of patterns and processes underlying geographic features in order to make better decisions and understand phenomena. The document outlines four types of spatial analysis: spatial data manipulation, spatial data analysis, spatial statistical analysis, and spatial modeling. It also describes different vector and raster spatial analysis techniques, such as clipping, overlaying, buffering, and slope/aspect calculations. Spatial modeling is defined as using models to predict spatial outcomes and enable "what if" analyses.
This document discusses GIS topology, which establishes rules for how geographic features share geometry and spatial relationships. Topology ensures data quality, enhances analysis, and manages coincident geometry. It has three components: connectivity between nodes and arcs, area definition using polygon boundaries, and contiguity to determine adjacent features. Topological rules prevent errors like overlaps, gaps, dangles and ensure proper containment of points and boundaries.
Topics:
1. Introduction to GIS
2. Components of GIS
3. Types of Data
4. Spatial Data
5. Non-Spatial Data
6. GIS Operations
7. Coordinate Systems
8. Datum
9. Map Projections
10. Raster Data Compression Techniques
11. GIS Software
12. Free GIS Data Resources
Topics:
1. Mapping Concepts
2. Analysis with paper based Maps
3. Limitations of Paper based Maps
4. Computer Aided Cartography History and Development
5. GIS Definition
6. Advantage of Digital Maps
Topics:
1. Introduction to Fluid Dynamics
2. Surface and Body Forces
3. Equations of Motion
- Reynold’s Equation
- Navier-Stokes Equation
- Euler’s Equation
- Bernoulli’s Equation
- Bernoulli’s Equation for Real Fluid
4. Applications of Bernoulli’s Equation
5. The Momentum Equation
6. Application of Momentum Equations
- Force exerted by flowing fluid on pipe bend
- Force exerted by the nozzle on the water
7. Measurement of Flow Rate
a). Venturimeter
b). Orifice Meter
c). Pitot Tube
8. Measurement of Flow Rate in Open Channels
a) Notches
b) Weirs
This document provides an overview of fluid kinematics, which is the study of fluid motion without considering forces. It discusses key concepts like streamlines, pathlines, and streaklines. It describes Lagrangian and Eulerian methods for describing fluid motion. It also covers various types of fluid flow such as steady/unsteady, laminar/turbulent, compressible/incompressible, and one/two/three-dimensional flow. Important topics like continuity equation, velocity, acceleration, and stream/velocity potential functions are also summarized. The document is intended to outline the syllabus and learning objectives for a course unit on fluid kinematics.
This document provides an overview of fluid pressure and measurement techniques. It begins with defining key concepts like hydrostatic pressure, Pascal's law, and pressure variation in static fluids. It then describes various devices used to measure pressure, including manometers (U-tube, single column, differential), and mechanical gauges (diaphragm, Bourdon tube, dead-weight, bellows). The document is divided into 5 units covering fluid statics, kinematics, dynamics, pipe flow, and dimensional analysis with the goal of teaching students to calculate pressure, hydrostatic forces, fluid flow, and losses in closed conduits.
This document provides an overview of reciprocating pumps. It begins by defining a reciprocating pump as a hydraulic machine that converts mechanical energy to hydraulic energy by sucking liquid into a cylinder using a reciprocating piston. It then covers the main parts of reciprocating pumps, classifications of piston and plunger pumps, the significance of air vessels, and provides examples of single and double acting pump working principles. The document also discusses discharge calculations, work done, power required and sources of slip. It concludes with advantages like high pressure delivery and disadvantages like high maintenance costs.
E-Waste or Electronic Waste may be defined as discarded computers, office electronic equipment, entertainment device electronics, mobile phones, television sets and refrigerators. This definition includes used electronics which are destined for reuse, resale, salvage, recycling, or disposal.
Biomedical Waste is any kind of waste that contains infectious material (or material that’s potentially infectious). This definition includes waste generated by healthcare facilities like physician’s offices, hospitals, dental practices, laboratories, medical research facilities, and veterinary clinics
This document defines and describes Digital Elevation Models (DEMs). It discusses that DEMs are 3D representations of land surface elevation from various data sources. There are two main types of DEMs - raster and vector (TIN). Data can be captured through remote sensing, photogrammetry, or land surveys. Free global DEMs are available from sources like SRTM, ASTER, and ALOS. DEMs have many applications including terrain analysis, hydrology, mapping, and more.
The word “Gymnosperm” comes from the Greek words “gymnos”(naked) and “sperma”(seed), hence known as “Naked seeds.” Gymnosperms are the seed-producing plants, but unlike angiosperms, they produce seeds without fruits. These plants develop on the surface of scales or leaves, or at the end of stalks forming a cone-like structure.
APM event held on 9 July in Bristol.
Speaker: Roy Millard
The SWWE Regional Network were very pleased to welcome back to Bristol Roy Millard, of APM’s Assurance Interest Group on 9 July 2024, to talk about project reviews and hopefully answer all your questions.
Roy outlined his extensive career and his experience in setting up the APM’s Assurance Specific Interest Group, as they were known then.
Using Mentimeter, he asked a number of questions of the audience about their experience of project reviews and what they wanted to know.
Roy discussed what a project review was and examined a number of definitions, including APM’s Bok: “Project reviews take place throughout the project life cycle to check the likely or actual achievement of the objectives specified in the project management plan”
Why do we do project reviews? Different stakeholders will have different views about this, but usually it is about providing confidence that the project will deliver the expected outputs and benefits, that it is under control.
There are many types of project reviews, including peer reviews, internal audit, National Audit Office, IPA, etc.
Roy discussed the principles behind the Three Lines of Defence Model:, First line looks at management controls, policies, procedures, Second line at compliance, such as Gate reviews, QA, to check that controls are being followed, and third Line is independent external reviews for the organisations Board, such as Internal Audit or NAO audit.
Factors which affect project reviews include the scope, level of independence, customer of the review, team composition and time.
Project Audits are a special type of project review. They are generally more independent, formal with clear processes and audit trails, with a greater emphasis on compliance. Project reviews are generally more flexible and informal, but should be evidence based and have some level of independence.
Roy looked at 2 examples of where reviews went wrong, London Underground Sub-Surface Upgrade signalling contract, and London’s Garden Bridge. The former had poor 3 lines of defence, no internal audit and weak procurement skills, the latter was a Boris Johnson vanity project with no proper governance due to Johnson’s pressure and interference.
Roy discussed the principles of assurance reviews from APM’s Guide to Integrated Assurance (Free to Members), which include: independence, accountability, risk based, and impact, etc
Human factors are important in project reviews. The skills and knowledge of the review team, building trust with the project team to avoid defensiveness, body language, and team dynamics, which can only be assessed face to face, active listening, flexibility and objectively.
Click here for further content: https://www.apm.org.uk/news/a-beginner-s-guide-to-project-reviews-everything-you-wanted-to-know-but-were-too-afraid-to-ask/
PRESS RELEASE - UNIVERSITY OF GHANA, JULY 16, 2024.pdfnservice241
The University of Ghana has launched a new vision and strategic plan, which will focus on transforming lives and societies through unparalleled scholarship, innovation, and result-oriented discoveries.
Topics to be Covered
Beginning of Pedagogy
What is Pedagogy?
Definition of Pedagogy
Features of Pedagogy
What Is Pedagogy In Teaching?
What Is Teacher Pedagogy?
What Is The Pedagogy Approach?
What are Pedagogy Approaches?
Teaching and Learning Pedagogical approaches?
Importance of Pedagogy in Teaching & Learning
Role of Pedagogy in Effective Learning
Pedagogy Impact on Learner
Pedagogical Skills
10 Innovative Learning Strategies For Modern Pedagogy
Types of Pedagogy
Lecture Notes Unit4 Chapter13 users , roles and privilegesMurugan146644
Description:
Welcome to the comprehensive guide on Relational Database Management System (RDBMS) concepts, tailored for final year B.Sc. Computer Science students affiliated with Alagappa University. This document covers fundamental principles and advanced topics in RDBMS, offering a structured approach to understanding databases in the context of modern computing. PDF content is prepared from the text book Learn Oracle 8I by JOSE A RAMALHO.
Key Topics Covered:
Main Topic : USERS, Roles and Privileges
In Oracle databases, users are individuals or applications that interact with the database. Each user is assigned specific roles, which are collections of privileges that define their access levels and capabilities. Privileges are permissions granted to users or roles, allowing actions like creating tables, executing procedures, or querying data. Properly managing users, roles, and privileges is essential for maintaining security and ensuring that users have appropriate access to database resources, thus supporting effective data management and integrity within the Oracle environment.
Sub-Topic :
Definition of User, User Creation Commands, Grant Command, Deleting a user, Privileges, System privileges and object privileges, Grant Object Privileges, Viewing a users, Revoke Object Privileges, Creation of Role, Granting privileges and roles to role, View the roles of a user , Deleting a role
Target Audience:
Final year B.Sc. Computer Science students at Alagappa University seeking a solid foundation in RDBMS principles for academic and practical applications.
URL for previous slides
chapter 8,9 and 10 : https://www.slideshare.net/slideshow/lecture_notes_unit4_chapter_8_9_10_rdbms-for-the-students-affiliated-by-alagappa-university/270123800
Chapter 11 Sequence: https://www.slideshare.net/slideshow/sequnces-lecture_notes_unit4_chapter11_sequence/270134792
Chapter 12 View : https://www.slideshare.net/slideshow/rdbms-lecture-notes-unit4-chapter12-view/270199683
About the Author:
Dr. S. Murugan is Associate Professor at Alagappa Government Arts College, Karaikudi. With 23 years of teaching experience in the field of Computer Science, Dr. S. Murugan has a passion for simplifying complex concepts in database management.
Disclaimer:
This document is intended for educational purposes only. The content presented here reflects the author’s understanding in the field of RDBMS as of 2024.
Benchmarking Sustainability: Neurosciences and AI Tech Research in Macau - Ke...Alvaro Barbosa
In this talk we will review recent research work carried out at the University of Saint Joseph and its partners in Macao. The focus of this research is in application of Artificial Intelligence and neuro sensing technology in the development of new ways to engage with brands and consumers from a business and design perspective. In addition we will review how these technologies impact resilience and how the University benchmarks these results against global standards in Sustainable Development.
Demonstration module in Odoo 17 - Odoo 17 SlidesCeline George
In Odoo, a module represents a unit of functionality that can be added to the Odoo system to extend its features or customize its behavior. Each module typically consists of various components, such as models, views, controllers, security rules, data files, and more. Lets dive into the structure of a module in Odoo 17
2. Unit 3: Directives
Built-in Directives:
• How to use Built-in Directives:
• Types:
Component Directives
Structural Directives
Attribute Directives.
Custom Directives:
• Creating a Custom Attribute Directive
• Creating a Custom Directive with a Component
6. Built-in Directives
Directives extend the behavior of HTML, enabling you to create custom HTML elements,
attributes, and classes with functionality specific to an application. Angular provides many
built-in directives, which provide the capability to interact with form elements, bind data in a
component to the view, and interact with browser events.
Using Built-in Directives
Much of the Angular functionality that you need to implement in HTML elements is provided
through built-in directives. These directives provide a wide variety of support for Angular
applications. The following sections describe most of the Angular directives, which fall into
three categories:
1. Component: A directive with a template
2. Structural: A directive that manipulates elements in the DOM
3. Attribute: A directive that manipulates the appearance and behavior of a DOM element
7. Components Directives
Directives in Angular is a .js class, which is declared as @directive. We have 3 directives in
Angular.
A @Component decorator is actually a @Directive decorator extended with template-
oriented features. Whenever Angular renders a directive, it changes the DOM according to
the instructions given by the directive. Directive appears within an element tag similar to
attributes.
8. Structural Directives
Structural directives alter layout by adding, removing, and replacing elements in DOM.
*ngIf
When this directive is present in an element, that element is added to the DOM if the value
returns true. If the value returns false, then that element is removed from the DOM,
preventing that element from using resources. Here is an example:
<div *ngIf="students.length > 0">
…..
</div
*ngFor
This directive is used to create a copy of a template for each item within an iterable object.
Here is an example:
<div *ngFor="let student of students">
<div>Name: {{student.name}} </div>
</div>
9. *ngIf
Syntax:
<p *ngIf="condition"> content to render, when the condition is true </p>
app.component.ts
contacts:any = [
{idno:"101",name: "Sravani", email:"sravani@gmail.com"},
{idno:"102",name: "Abhinandan", email:"abhinandan@gmail.com"},
{idno:"103",name: "Maruti", email:"maruti@gmail.com"},
{idno:"104",name: "Kamalesh", email:"kamalesh@gmail.com"}
];
app.component.html
<div *ngIf="contacts.length>0">
<h5 class="text-center text-success">Some Content is there to display</h5>
</div>
10. *ngIf with else condition:
Syntax:
<div *ngIf="condition; then normal else elseBlock"></div>
<ng-template #normal>
Content to render when condition is true.
</ng-template>
<ng-template #elseBlock>
Content to render when condition is false.
</ng-template>
app.component.ts:
contacts:any = [];
app.component.ts:
<div *ngIf=" contacts.length >0; then fullContent else emptycontent">here is ignored</div>
<ng-template #fullContent>
<h3 class="text-center text-success">Some content is thre in declared variable</h3>
</ng-template>
<ng-template #emptycontent>
<h3 class="text-center text-danger">provided variable dont have content</h3>
</ng-template>
11. *ngFor
This directive works like a loop.
app.component.ts:
contacts:any = [
{idno:"101",name: "Sravani", email:"sravani@gmail.com"},
{idno:"102",name: "Abhinandan", email:"abhinandan@gmail.com"},
{idno:"103",name: "Maruti", email:"maruti@gmail.com"},
{idno:"104",name: "Kamalesh", email:"kamalesh@gmail.com"}
];
13. ngSwitch
This directive displays a template based on the value passed in it. As with ngIf, if
the value does not match the case, the element is not created. Here is an example:
<div [ngSwitch]=“student">
<span *ngSwitchCase = “ ‘Mohan’ “ > Hello Mohan </span>
<span *ngSwitchCase = “ ‘Vijay’ “ > Hello Vijay </span>
<span *ngSwitchDefault > Hello Student </span>
</div>
The ngSwitch directive relies on two other directives to work:
ngSwitchCase and ngSwitchDefault. These directives are be explained below.
ngSwitchCase:
This directive evaluates the value it has stored against the value passed into
ngSwitch and determines whether the HTML template it is attached to should be
created.
ngSwitchDefault:
This directive creates the HTML template if all the above ngSwitchCase
expressions evaluate to false. This ensures that some HTML is generated no
14. Attribute Directives
Angular attribute directives modify how HTML elements look and behave. They are injected
straight into the HTML and dynamically modify how the user interacts with an HTML
segment. Attribute directives are so named because they often look like normal HTML
attributes.
ngModel
This directive watches a variable for changes and then updates display values based on
those changes. Consider these examples:
app.component.html:
<input type="text" name="data" [(ngModel)]="data" />
<p> {{ data }} </p>
app.component.ts:
15. ngStyle
This directive updates the styles of an HTML element.
app.component.html:
Example 1:
<div class="col-md-4" [ngStyle]="{'background-color':'green'}">Hello</div>
Example 2:
<div [ngStyle]="{'background-color’: country === 'UK' ? 'yellow' : 'red' }">
{{country}}</div>
app.component.ts:
country:any= 'UK’;
utput:
16. ngClass
It controls the appearance of elements by adding and removing CSS classes
dynamically.
app.component.html:
<div [ngClass]=“ {'text-primary': country === 'UK’}” > {{country}} </div>
app.component.ts:
country:any= 'UK’;
output:
UK
ngForm
This directive creates a form group and allows it to track the values and validation
within that form group. By using ngSubmit, you can pass the form data as an
object to the submission event. Here is an example:
app.component.html:
<form #formName="ngForm" (ngSubmit)="onSubmit(formName)"> </form
17. Custom Directives
Creating a custom directive is just like creating an Angular component. To create a custom
directive we have to replace @Component decorator with @Directive decorator.
So, let's get started with creating our first Custom Attribute directive. In this directive, we
are going to highlight the selected DOM element by setting an element’s background color.
Procedure:
Step 1: Create Custom Directive ‘appHighlight’
ng generate directive appHighlight
19. Dr. Rambabu Palaka
Professor
School of Engineering
Malla Reddy University, Hyderabad
Mobile: +91-9652665840
Email: drrambabu@mallareddyuniversity.ac.in
Reference:
Node.js, MongoDB and Angular Web Development
by Brad Dayley, Brenden Dayley, Caleb Daley