SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler offline
ANGULARJS II
Por Ismael Gomes Costa
Cronograma
1. Filters
2. Filters Embedded
3. Form Validation
4. $pristine, $dirty, $error
5. Injeção de Dependências
6. Services
7. Scopes
8. Testes unitários
9. Automatizando o fluxo
ANGULARJS II
ANGULARJS II
Por Ismael Gomes Costa
FILTERS
Filters
ANGULARJS II
 Filtro simples:
{{expression | filter}}
 Filtro combinado:
{{expression | filter1 | filter2}}
ANGULARJS II
Por Ismael Gomes Costa
FILTERS EMBEDDED
Filters Embedded - Currency
ANGULARJS II
 Currency:
{{ 10 | currency}} = $10.00
{{ 10 | currency: 'R$‘ }} = R$10.00
 Internacionaliação
<script src="js/lib/angular-locale_pt-br.js"></script>
{{ 10 | currency: 'R$‘ }} = R$10,00
 Referência:
https://docs.angularjs.org/api/ng/filter/currency
Filters Embedded - Date
ANGULARJS II
 Date:
{{ data | date }} = Dec 10, 2013.
{{ data | date:'MMMM dd/MM/yyyy HH:mm:ss' }} = December 10/12/2013 21:42:10
 Internacionaliação
<script src="js/lib/angular-locale_pt-br.js"></script>
{{ data | date:'MMMM dd/MM/yyyy HH:mm:ss' }} = Dezembro 10/12/2013 21:42:10
 Referência:
https://docs.angularjs.org/api/ng/filter/date
Filters Embedded - Json
ANGULARJS II
 json:
{{ car | json }} =
{
"plate": "6MBV006",
"color": "Blue",
"entrance": "2013-12-09T23:46:15.186Z"
}
 Referência:
https://docs.angularjs.org/api/ng/filter/json
Filters Embedded - Outros
ANGULARJS II
 limitTo:
MinhaStringCompleta = {{ expression | limitTo:10 }} = MinhaStrin
 Lowercase:
MinhaString = {{ expression | lowercase }} = minhastring
 OrderBy:
{{ expression | orderBy:predicate:reverse }}
https://docs.angularjs.org/api/ng/filter/orderBy
ANGULARJS II
Por Ismael Gomes Costa
FORM VALIDATION
Form Validation
ANGULARJS II
<input
type="text"
name="plateField"
ng-model="car.plate"
placeholder="What's the plate?"
ng-required="true"
/>
<input
type="text"
name="plateField"
ng-model="car.plate"
placeholder="What's the plate?"
ng-required="true"
ng-minlength="6"
ng-maxlength="10"
/>
Form Validation
ANGULARJS II
<input
type="text"
name="plateField"
ng-model="car.plate"
placeholder="What's the plate?"
ng-required="true"
ng-minlength="6"
ng-maxlength="10"
ng-pattern="/[A-Z]{3}[0-9]{3,7}/"
/>
ANGULARJS II
Por Ismael Gomes Costa
$pristine, $dirty, $error
$pristine, $dirty, $error
ANGULARJS II
 $pristine:
Verifica se o valor está limpo (não foi alterado nenhuma
vez durante a edição do form)
 $dirty
Verifica se o valor está sujo (já foi alterado em algum
momento durante a edição do form)
$pristine, $dirty, $error
ANGULARJS II
 $error:
Verifica se o form está inválido.
<alert ng-show="carForm.plateField.$dirty && carForm.plateField.$invalid"
topic="Something went wrong!">
<span ng-show="carForm.plateField.$error.required">
You must inform the plate of the car!
</span>
<span ng-show="carForm.plateField.$error.minlength">
The plate must have at least 6 characters!
</span>
<span ng-show="carForm.plateField.$error.maxlength">
The plate must have at most 10 characters!
</span>
<span ng-show="carForm.plateField.$error.pattern">
The plate must start with non-digits, followed by 4 to 7
numbers!
</span>
</alert>
ANGULARJS II
Por Ismael Gomes Costa
Services
Services
ANGULARJS II
 Singleton - Cada componente dependente de um
serviço obtém uma referência à única instância
gerado pela service factory.
 Lazily instantiated – Angular só instancia um service
quando um componente da aplicação depende dele.
ANGULARJS II
Por Ismael Gomes Costa
Scopes
Scopes
ANGULARJS II
 $scope - Cada controller e diretiva tem o seu.
 $rootScope – Global, use com moderação (nunca, se
for possível).
Scopes - $scope
ANGULARJS II
 Pode ser isolado ou não.
 Pode acessar valores dos escopos pai caso a um
controller esteja dentro do outro.
<div ng-controller="MyController">
<div ng-controller="MyController2">
</div>
</div>
ANGULARJS II
Por Ismael Gomes Costa
Testes Unitários
Testes Unitários
ANGULARJS II
 Jasmine - Testes.
 Karma – Roda os testes do Jasmine.
ANGULARJS II
Por Ismael Gomes Costa
Automatizando o fluxo
Testes Unitários
ANGULARJS II
 GruntJS.
 Bower.
ANGULARJS II
 BRANAS, Rodrigo. AngularJS Essentials:
Design and construct reusable, maintainable,
and modular web applications with AgularJS.
Bombaim:Birmingham, 2014.
 https://docs.angularjs.org/guide
Referências Bibliográficas

Mais conteúdo relacionado

Destaque

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Angularjs II

  • 2. Cronograma 1. Filters 2. Filters Embedded 3. Form Validation 4. $pristine, $dirty, $error 5. Injeção de Dependências 6. Services 7. Scopes 8. Testes unitários 9. Automatizando o fluxo ANGULARJS II
  • 3. ANGULARJS II Por Ismael Gomes Costa FILTERS
  • 4. Filters ANGULARJS II  Filtro simples: {{expression | filter}}  Filtro combinado: {{expression | filter1 | filter2}}
  • 5. ANGULARJS II Por Ismael Gomes Costa FILTERS EMBEDDED
  • 6. Filters Embedded - Currency ANGULARJS II  Currency: {{ 10 | currency}} = $10.00 {{ 10 | currency: 'R$‘ }} = R$10.00  Internacionaliação <script src="js/lib/angular-locale_pt-br.js"></script> {{ 10 | currency: 'R$‘ }} = R$10,00  Referência: https://docs.angularjs.org/api/ng/filter/currency
  • 7. Filters Embedded - Date ANGULARJS II  Date: {{ data | date }} = Dec 10, 2013. {{ data | date:'MMMM dd/MM/yyyy HH:mm:ss' }} = December 10/12/2013 21:42:10  Internacionaliação <script src="js/lib/angular-locale_pt-br.js"></script> {{ data | date:'MMMM dd/MM/yyyy HH:mm:ss' }} = Dezembro 10/12/2013 21:42:10  Referência: https://docs.angularjs.org/api/ng/filter/date
  • 8. Filters Embedded - Json ANGULARJS II  json: {{ car | json }} = { "plate": "6MBV006", "color": "Blue", "entrance": "2013-12-09T23:46:15.186Z" }  Referência: https://docs.angularjs.org/api/ng/filter/json
  • 9. Filters Embedded - Outros ANGULARJS II  limitTo: MinhaStringCompleta = {{ expression | limitTo:10 }} = MinhaStrin  Lowercase: MinhaString = {{ expression | lowercase }} = minhastring  OrderBy: {{ expression | orderBy:predicate:reverse }} https://docs.angularjs.org/api/ng/filter/orderBy
  • 10. ANGULARJS II Por Ismael Gomes Costa FORM VALIDATION
  • 11. Form Validation ANGULARJS II <input type="text" name="plateField" ng-model="car.plate" placeholder="What's the plate?" ng-required="true" /> <input type="text" name="plateField" ng-model="car.plate" placeholder="What's the plate?" ng-required="true" ng-minlength="6" ng-maxlength="10" />
  • 12. Form Validation ANGULARJS II <input type="text" name="plateField" ng-model="car.plate" placeholder="What's the plate?" ng-required="true" ng-minlength="6" ng-maxlength="10" ng-pattern="/[A-Z]{3}[0-9]{3,7}/" />
  • 13. ANGULARJS II Por Ismael Gomes Costa $pristine, $dirty, $error
  • 14. $pristine, $dirty, $error ANGULARJS II  $pristine: Verifica se o valor está limpo (não foi alterado nenhuma vez durante a edição do form)  $dirty Verifica se o valor está sujo (já foi alterado em algum momento durante a edição do form)
  • 15. $pristine, $dirty, $error ANGULARJS II  $error: Verifica se o form está inválido. <alert ng-show="carForm.plateField.$dirty && carForm.plateField.$invalid" topic="Something went wrong!"> <span ng-show="carForm.plateField.$error.required"> You must inform the plate of the car! </span> <span ng-show="carForm.plateField.$error.minlength"> The plate must have at least 6 characters! </span> <span ng-show="carForm.plateField.$error.maxlength"> The plate must have at most 10 characters! </span> <span ng-show="carForm.plateField.$error.pattern"> The plate must start with non-digits, followed by 4 to 7 numbers! </span> </alert>
  • 16. ANGULARJS II Por Ismael Gomes Costa Services
  • 17. Services ANGULARJS II  Singleton - Cada componente dependente de um serviço obtém uma referência à única instância gerado pela service factory.  Lazily instantiated – Angular só instancia um service quando um componente da aplicação depende dele.
  • 18. ANGULARJS II Por Ismael Gomes Costa Scopes
  • 19. Scopes ANGULARJS II  $scope - Cada controller e diretiva tem o seu.  $rootScope – Global, use com moderação (nunca, se for possível).
  • 20. Scopes - $scope ANGULARJS II  Pode ser isolado ou não.  Pode acessar valores dos escopos pai caso a um controller esteja dentro do outro. <div ng-controller="MyController"> <div ng-controller="MyController2"> </div> </div>
  • 21. ANGULARJS II Por Ismael Gomes Costa Testes Unitários
  • 22. Testes Unitários ANGULARJS II  Jasmine - Testes.  Karma – Roda os testes do Jasmine.
  • 23. ANGULARJS II Por Ismael Gomes Costa Automatizando o fluxo
  • 24. Testes Unitários ANGULARJS II  GruntJS.  Bower.
  • 25. ANGULARJS II  BRANAS, Rodrigo. AngularJS Essentials: Design and construct reusable, maintainable, and modular web applications with AgularJS. Bombaim:Birmingham, 2014.  https://docs.angularjs.org/guide Referências Bibliográficas