SlideShare a Scribd company logo
Five Common Angular Mistakes 
Angular is a powerful tool for managing the display of data. 
However, like any powerful tool there can be trouble if misused. 
Below we’ll look at some common AngularJS mistakes. They 
vary in severity, but ultimately can conspire to make developing 
an AngularJS application more of a headache than it needs to 
be. We’ll cover five of these common mistakes, and ways to 
avoid them. 
Mistake 1 – Improper Event Handler Usage 
Angular’s scope object is, according to the Angular docs, the “glue between 
application controller and the view.” To be more specific, the scope is intended 
to hold all of the data needed for your views to present the page to the 
user. The Angular scope is very flexible, allowing for a number of custom 
functions to be written based upon the populated contents. This can be a very 
seductive tool for coders coming from a more imperative-style background. 
The temptation to add code like: 
www.backand.com
can be great, particularly when it just makes sense to add functionality 
based on data displayed thus far (such as displaying a custom button based 
upon user input). However, this violates one of the core principles of Angular 
development (and web development in general) – keep your display and your 
logic as separated as possible. With Angular having a declarative focus, this 
type of coding can become unwieldy very quickly. 
Mistake 2 – Nested Scope Binding 
Like any other programming language, Angular comes with its own scope 
nesting rules. A naïve implementation of inputs bound to a model, for 
example, can lead to a general breakdown in the binding process. In essence, 
the problem comes down to making sure names are fully qualified. Let’s say 
you have a controller defined as follows: 
Any subsequent access to the index element will result in local changes only. 
This is largely due to how scopes handle Javascript primitive objects – in 
subsequent scope contexts, these scope elements will actually be duplicated 
– modifying the “dollars” element, for example, will result in no changes to 
any elements tied to the primitive. In essence, this means that primitives are 
passed by value, while non-primitives (such as objects and arrays) are passed 
by reference. To fix this, simply structure your scope objects as, well, objects: 
Due to the modification to store index in a non-primitive type, all “magic” 
angular binding should work properly – you just need to change references 
to the data to be of the style “customerData.index”. 
Mistake 3 – Too-Complex Controllers 
One of the common pitfalls of compressed development time lines and 
rushed coding jobs is code that tries to do too much within a given context. 
Developing a decent program architecture is a time-consuming endeavor, and 
is something that is often given short shrift once time becomes a precious 
resource. Thus, it is common among these kinds of code bases to mix logic 
layers, and have controllers perform too many tasks. For example, performing 
www.backand.com
AJAX calls in controllers, when they truly belong in services, or having way too 
many event handlers than are needed to accomplish the task at hand. 
The best way to avoid this is to stick to your guns in design and development. 
Make your project stakeholders understand that good code must not just 
work, it needs to be both well-written and maintainable as well. A clear 
separation between functionality layers – keeping DOM manipulation in 
directives, ensuring the display layer focuses exclusively on data display, and 
so on – helps to not only reduce bugs in the codebase, but to also ease future 
extensions of the developed functionality. 
Mistake 4 – Ignoring the Tools Available 
One of the most frustrating things for nearly any person trying to help 
an aspiring programmer is when they fail to make adequate use of the 
tools available. Chrome and Firefox, for example, include a full-featured 
development suite that covers profiling, debugging, and error output. This 
allows a developer to develop more iteratively in the browser, finding and 
troubleshooting errors very quickly. A common example of this is the console 
log – Angular errors are often printed on the console log, with more than 
enough information to provide a start to the troubleshooting process. This 
is particularly an issue during the learning process, when finding your way 
through Angular code for the first time. It can be far too easy to rely upon 
asking questions and having someone give you answers. Thus, it should be a 
best practice to always check the console output before hunting for solutions 
– a number of seemingly complex errors boil down to a simple error reported 
in the browser. 
Mistake 5 – Non-Idiomatic Code 
Angular is developed with a declarative style of programming in mind. It 
was designed to serve as an extension of HTML, meaning that it wants to 
present the data based on a concrete set of rules. In other words, once the 
data is displayed the DOM should be changed as little as possible. Trying 
to approach this type of programming from a jQuery perspective – where 
imperative programming is used to drive DOM changes in a procedural 
approach – can quickly make your code a mess. While relying upon what you 
know can be a quick draw for a programmer looking to get something up and 
running quickly, Angular becomes a lot easier to use when developed along 
the intended paths. 
www.backand.com
Conclusion 
The above list of common issues with Angular development is not exhaustive 
– far from it. However, the issues presented above are exceedingly common 
among neophyte Angular developers. Some are architectural in nature, and as 
such not necessarily Angular-specific, but quirks like scope handling in Angular 
can catch even seasoned developers off-guard. Keep the above in mind as you 
develop your code, and you’ll find yourself with a lot fewer headaches. 
www.backand.com 
Contact Information 
Backand Inc. 
info@backand.com 
www.backand.com

More Related Content

What's hot

Webcomponents TLV October 2014
Webcomponents TLV October 2014Webcomponents TLV October 2014
Webcomponents TLV October 2014
Dmitry Bakaleinik
 
web designing course bangalore
web designing course bangaloreweb designing course bangalore
web designing course bangalore
Infocampus Logics Pvt.Ltd.
 
Gwt Presentation 1
Gwt Presentation 1Gwt Presentation 1
Gwt Presentation 1
Jetti Chowdary
 
B4UConference_Sexy Angular Stack
B4UConference_Sexy Angular StackB4UConference_Sexy Angular Stack
B4UConference_Sexy Angular Stack
Hoa Le
 
How To be a Backend developer
How To be a Backend developer    How To be a Backend developer
How To be a Backend developer
Ramy Hakam
 
Html5
Html5Html5
No brainer
No brainerNo brainer
No brainer
Tanzim Saqib
 
Frontend Development vs Backend Development | Detailed Comparison
Frontend Development vs Backend Development | Detailed ComparisonFrontend Development vs Backend Development | Detailed Comparison
Frontend Development vs Backend Development | Detailed Comparison
Mariya James
 
Dumb and smart components + redux (1)
Dumb and smart components + redux (1)Dumb and smart components + redux (1)
Dumb and smart components + redux (1)
Brecht Billiet
 
Website Development Using a Headless CMS - Sean Lamacraft, Distinction
Website Development Using a Headless CMS - Sean Lamacraft, DistinctionWebsite Development Using a Headless CMS - Sean Lamacraft, Distinction
Website Development Using a Headless CMS - Sean Lamacraft, Distinction
Kentico Software
 
Agular in a microservices world
Agular in a microservices worldAgular in a microservices world
Agular in a microservices world
Brecht Billiet
 
Your First ASP_Net project part 1
Your First ASP_Net project part 1Your First ASP_Net project part 1
Your First ASP_Net project part 1
Biswadip Goswami
 
iWeb NJECC June 28, 2011 DAndrea
iWeb NJECC June 28, 2011 DAndreaiWeb NJECC June 28, 2011 DAndrea
iWeb NJECC June 28, 2011 DAndreaD'Andrea
 
Headless CMS for Digital Agencies - Case Study by Andy Thompson
Headless CMS for Digital Agencies - Case Study by Andy ThompsonHeadless CMS for Digital Agencies - Case Study by Andy Thompson
Headless CMS for Digital Agencies - Case Study by Andy Thompson
Kentico Software
 
MEAN Vs MERN Stack | Detailed Comparison Between MEAN & MERN Stack
MEAN Vs MERN Stack | Detailed Comparison Between MEAN & MERN StackMEAN Vs MERN Stack | Detailed Comparison Between MEAN & MERN Stack
MEAN Vs MERN Stack | Detailed Comparison Between MEAN & MERN Stack
Mariya James
 
How Magento Front-end is Going from Zero to Hero
How Magento Front-end is Going from Zero to HeroHow Magento Front-end is Going from Zero to Hero
How Magento Front-end is Going from Zero to Hero
Bartek Igielski
 

What's hot (20)

Webcomponents TLV October 2014
Webcomponents TLV October 2014Webcomponents TLV October 2014
Webcomponents TLV October 2014
 
web designing course bangalore
web designing course bangaloreweb designing course bangalore
web designing course bangalore
 
Gwt Presentation 1
Gwt Presentation 1Gwt Presentation 1
Gwt Presentation 1
 
B4UConference_Sexy Angular Stack
B4UConference_Sexy Angular StackB4UConference_Sexy Angular Stack
B4UConference_Sexy Angular Stack
 
How To be a Backend developer
How To be a Backend developer    How To be a Backend developer
How To be a Backend developer
 
Html5
Html5Html5
Html5
 
No brainer
No brainerNo brainer
No brainer
 
Frontend Development vs Backend Development | Detailed Comparison
Frontend Development vs Backend Development | Detailed ComparisonFrontend Development vs Backend Development | Detailed Comparison
Frontend Development vs Backend Development | Detailed Comparison
 
Dopp xhtml tutorial
Dopp xhtml tutorialDopp xhtml tutorial
Dopp xhtml tutorial
 
Dumb and smart components + redux (1)
Dumb and smart components + redux (1)Dumb and smart components + redux (1)
Dumb and smart components + redux (1)
 
Website Development Using a Headless CMS - Sean Lamacraft, Distinction
Website Development Using a Headless CMS - Sean Lamacraft, DistinctionWebsite Development Using a Headless CMS - Sean Lamacraft, Distinction
Website Development Using a Headless CMS - Sean Lamacraft, Distinction
 
Walther Mvc
Walther MvcWalther Mvc
Walther Mvc
 
Agular in a microservices world
Agular in a microservices worldAgular in a microservices world
Agular in a microservices world
 
ASP.NET Web Forms vs. MVC
ASP.NET Web Forms vs. MVCASP.NET Web Forms vs. MVC
ASP.NET Web Forms vs. MVC
 
Html5
Html5Html5
Html5
 
Your First ASP_Net project part 1
Your First ASP_Net project part 1Your First ASP_Net project part 1
Your First ASP_Net project part 1
 
iWeb NJECC June 28, 2011 DAndrea
iWeb NJECC June 28, 2011 DAndreaiWeb NJECC June 28, 2011 DAndrea
iWeb NJECC June 28, 2011 DAndrea
 
Headless CMS for Digital Agencies - Case Study by Andy Thompson
Headless CMS for Digital Agencies - Case Study by Andy ThompsonHeadless CMS for Digital Agencies - Case Study by Andy Thompson
Headless CMS for Digital Agencies - Case Study by Andy Thompson
 
MEAN Vs MERN Stack | Detailed Comparison Between MEAN & MERN Stack
MEAN Vs MERN Stack | Detailed Comparison Between MEAN & MERN StackMEAN Vs MERN Stack | Detailed Comparison Between MEAN & MERN Stack
MEAN Vs MERN Stack | Detailed Comparison Between MEAN & MERN Stack
 
How Magento Front-end is Going from Zero to Hero
How Magento Front-end is Going from Zero to HeroHow Magento Front-end is Going from Zero to Hero
How Magento Front-end is Going from Zero to Hero
 

Viewers also liked

The Enterprise Excel Hell
The Enterprise Excel HellThe Enterprise Excel Hell
The Enterprise Excel Hell
Backand Cohen
 
How-to Increase User Engagement by 25% with User Segmented Push Notifications
How-to Increase User Engagement by 25% with User Segmented Push NotificationsHow-to Increase User Engagement by 25% with User Segmented Push Notifications
How-to Increase User Engagement by 25% with User Segmented Push Notifications
Backand Cohen
 
Testing Two-Way Data Binding in AngularJS
Testing Two-Way Data Binding in AngularJSTesting Two-Way Data Binding in AngularJS
Testing Two-Way Data Binding in AngularJS
Backand Cohen
 
Backand Presentation
Backand PresentationBackand Presentation
Backand Presentation
Backand Cohen
 
How to Build Dynamic Forms in Angular Directive with a Backend
How to Build Dynamic Forms in Angular Directive with a BackendHow to Build Dynamic Forms in Angular Directive with a Backend
How to Build Dynamic Forms in Angular Directive with a Backend
Backand Cohen
 
AngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro FrameworkAngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro Framework
Backand Cohen
 
REST Easy with AngularJS - ng-grid CRUD Example
REST Easy with AngularJS - ng-grid CRUD ExampleREST Easy with AngularJS - ng-grid CRUD Example
REST Easy with AngularJS - ng-grid CRUD Example
Backand Cohen
 

Viewers also liked (7)

The Enterprise Excel Hell
The Enterprise Excel HellThe Enterprise Excel Hell
The Enterprise Excel Hell
 
How-to Increase User Engagement by 25% with User Segmented Push Notifications
How-to Increase User Engagement by 25% with User Segmented Push NotificationsHow-to Increase User Engagement by 25% with User Segmented Push Notifications
How-to Increase User Engagement by 25% with User Segmented Push Notifications
 
Testing Two-Way Data Binding in AngularJS
Testing Two-Way Data Binding in AngularJSTesting Two-Way Data Binding in AngularJS
Testing Two-Way Data Binding in AngularJS
 
Backand Presentation
Backand PresentationBackand Presentation
Backand Presentation
 
How to Build Dynamic Forms in Angular Directive with a Backend
How to Build Dynamic Forms in Angular Directive with a BackendHow to Build Dynamic Forms in Angular Directive with a Backend
How to Build Dynamic Forms in Angular Directive with a Backend
 
AngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro FrameworkAngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro Framework
 
REST Easy with AngularJS - ng-grid CRUD Example
REST Easy with AngularJS - ng-grid CRUD ExampleREST Easy with AngularJS - ng-grid CRUD Example
REST Easy with AngularJS - ng-grid CRUD Example
 

Similar to Five Common Angular Mistakes

How backbone.js is different from ember.js?
How backbone.js is different from ember.js?How backbone.js is different from ember.js?
How backbone.js is different from ember.js?
SoftProdigy - We know software!
 
AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)
Alex Ross
 
Top 13 Mistakes Committed by Angular Java script Developers
Top 13 Mistakes Committed by Angular Java script DevelopersTop 13 Mistakes Committed by Angular Java script Developers
Top 13 Mistakes Committed by Angular Java script Developers
Sarah Elson
 
Which technology has a better future_ AngularJS or ReactJS_.pdf
Which technology has a better future_ AngularJS or ReactJS_.pdfWhich technology has a better future_ AngularJS or ReactJS_.pdf
Which technology has a better future_ AngularJS or ReactJS_.pdf
Moon Technolabs Pvt. Ltd.
 
Top 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppTop 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular App
Katy Slemon
 
React js vs angularjs which framework to choose in 2022_
React js vs angularjs  which framework to choose in 2022_React js vs angularjs  which framework to choose in 2022_
React js vs angularjs which framework to choose in 2022_
Moon Technolabs Pvt. Ltd.
 
Best Practices to Ace ReactJS Web Development!
Best Practices to Ace ReactJS Web Development!Best Practices to Ace ReactJS Web Development!
Best Practices to Ace ReactJS Web Development!
Inexture Solutions
 
Maintainable Javascript carsonified
Maintainable Javascript carsonifiedMaintainable Javascript carsonified
Maintainable Javascript carsonifiedChristian Heilmann
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
Chirag Parmar
 
Angular js
Angular jsAngular js
Angular js
ymtech
 
Angular vs.pdf
Angular vs.pdfAngular vs.pdf
Angular vs.pdf
SophiaJasper
 
AngularJS – What, Why, Advantages and Disadvantages
AngularJS – What, Why, Advantages and DisadvantagesAngularJS – What, Why, Advantages and Disadvantages
AngularJS – What, Why, Advantages and Disadvantages
karenmsmith0504
 
How to choose the best frontend framework in 2022
How to choose the best frontend framework in 2022How to choose the best frontend framework in 2022
How to choose the best frontend framework in 2022
Katy Slemon
 
Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure
rupeshchanchal
 
Client Side Performance In Web Applications
Client Side Performance In Web ApplicationsClient Side Performance In Web Applications
Client Side Performance In Web Applications
vladungureanu
 
Vue Or React - Which One is the Best_.pptx
Vue Or React - Which One is the Best_.pptxVue Or React - Which One is the Best_.pptx
Vue Or React - Which One is the Best_.pptx
75waytechnologies
 
Angular Best Practices To Build Clean and Performant Web Applications
Angular Best Practices To Build Clean and Performant Web ApplicationsAngular Best Practices To Build Clean and Performant Web Applications
Angular Best Practices To Build Clean and Performant Web Applications
Albiorix Technology
 
Best practices to optimize code and build robust and scalable web applications
Best practices to optimize code and build robust and scalable web applicationsBest practices to optimize code and build robust and scalable web applications
Best practices to optimize code and build robust and scalable web applicationsdheerajpiet
 
9 Best JavaScript Frameworks To Choose
9 Best JavaScript Frameworks To Choose9 Best JavaScript Frameworks To Choose
9 Best JavaScript Frameworks To Choose
Albiorix Technology
 

Similar to Five Common Angular Mistakes (20)

How backbone.js is different from ember.js?
How backbone.js is different from ember.js?How backbone.js is different from ember.js?
How backbone.js is different from ember.js?
 
AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)AngularJS in Production (CTO Forum)
AngularJS in Production (CTO Forum)
 
Top 13 Mistakes Committed by Angular Java script Developers
Top 13 Mistakes Committed by Angular Java script DevelopersTop 13 Mistakes Committed by Angular Java script Developers
Top 13 Mistakes Committed by Angular Java script Developers
 
Which technology has a better future_ AngularJS or ReactJS_.pdf
Which technology has a better future_ AngularJS or ReactJS_.pdfWhich technology has a better future_ AngularJS or ReactJS_.pdf
Which technology has a better future_ AngularJS or ReactJS_.pdf
 
Top 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular AppTop 7 Angular Best Practices to Organize Your Angular App
Top 7 Angular Best Practices to Organize Your Angular App
 
React js vs angularjs which framework to choose in 2022_
React js vs angularjs  which framework to choose in 2022_React js vs angularjs  which framework to choose in 2022_
React js vs angularjs which framework to choose in 2022_
 
Best Practices to Ace ReactJS Web Development!
Best Practices to Ace ReactJS Web Development!Best Practices to Ace ReactJS Web Development!
Best Practices to Ace ReactJS Web Development!
 
Maintainable Javascript carsonified
Maintainable Javascript carsonifiedMaintainable Javascript carsonified
Maintainable Javascript carsonified
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Angular js
Angular jsAngular js
Angular js
 
Angular vs.pdf
Angular vs.pdfAngular vs.pdf
Angular vs.pdf
 
AngularJS – What, Why, Advantages and Disadvantages
AngularJS – What, Why, Advantages and DisadvantagesAngularJS – What, Why, Advantages and Disadvantages
AngularJS – What, Why, Advantages and Disadvantages
 
How to choose the best frontend framework in 2022
How to choose the best frontend framework in 2022How to choose the best frontend framework in 2022
How to choose the best frontend framework in 2022
 
Software Development Standard Operating Procedure
Software Development Standard Operating Procedure Software Development Standard Operating Procedure
Software Development Standard Operating Procedure
 
Client Side Performance In Web Applications
Client Side Performance In Web ApplicationsClient Side Performance In Web Applications
Client Side Performance In Web Applications
 
Vue Or React - Which One is the Best_.pptx
Vue Or React - Which One is the Best_.pptxVue Or React - Which One is the Best_.pptx
Vue Or React - Which One is the Best_.pptx
 
Angular Best Practices To Build Clean and Performant Web Applications
Angular Best Practices To Build Clean and Performant Web ApplicationsAngular Best Practices To Build Clean and Performant Web Applications
Angular Best Practices To Build Clean and Performant Web Applications
 
Best practices to optimize code and build robust and scalable web applications
Best practices to optimize code and build robust and scalable web applicationsBest practices to optimize code and build robust and scalable web applications
Best practices to optimize code and build robust and scalable web applications
 
Training On Angular Js
Training On Angular JsTraining On Angular Js
Training On Angular Js
 
9 Best JavaScript Frameworks To Choose
9 Best JavaScript Frameworks To Choose9 Best JavaScript Frameworks To Choose
9 Best JavaScript Frameworks To Choose
 

Recently uploaded

Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 

Recently uploaded (20)

Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 

Five Common Angular Mistakes

  • 1. Five Common Angular Mistakes Angular is a powerful tool for managing the display of data. However, like any powerful tool there can be trouble if misused. Below we’ll look at some common AngularJS mistakes. They vary in severity, but ultimately can conspire to make developing an AngularJS application more of a headache than it needs to be. We’ll cover five of these common mistakes, and ways to avoid them. Mistake 1 – Improper Event Handler Usage Angular’s scope object is, according to the Angular docs, the “glue between application controller and the view.” To be more specific, the scope is intended to hold all of the data needed for your views to present the page to the user. The Angular scope is very flexible, allowing for a number of custom functions to be written based upon the populated contents. This can be a very seductive tool for coders coming from a more imperative-style background. The temptation to add code like: www.backand.com
  • 2. can be great, particularly when it just makes sense to add functionality based on data displayed thus far (such as displaying a custom button based upon user input). However, this violates one of the core principles of Angular development (and web development in general) – keep your display and your logic as separated as possible. With Angular having a declarative focus, this type of coding can become unwieldy very quickly. Mistake 2 – Nested Scope Binding Like any other programming language, Angular comes with its own scope nesting rules. A naïve implementation of inputs bound to a model, for example, can lead to a general breakdown in the binding process. In essence, the problem comes down to making sure names are fully qualified. Let’s say you have a controller defined as follows: Any subsequent access to the index element will result in local changes only. This is largely due to how scopes handle Javascript primitive objects – in subsequent scope contexts, these scope elements will actually be duplicated – modifying the “dollars” element, for example, will result in no changes to any elements tied to the primitive. In essence, this means that primitives are passed by value, while non-primitives (such as objects and arrays) are passed by reference. To fix this, simply structure your scope objects as, well, objects: Due to the modification to store index in a non-primitive type, all “magic” angular binding should work properly – you just need to change references to the data to be of the style “customerData.index”. Mistake 3 – Too-Complex Controllers One of the common pitfalls of compressed development time lines and rushed coding jobs is code that tries to do too much within a given context. Developing a decent program architecture is a time-consuming endeavor, and is something that is often given short shrift once time becomes a precious resource. Thus, it is common among these kinds of code bases to mix logic layers, and have controllers perform too many tasks. For example, performing www.backand.com
  • 3. AJAX calls in controllers, when they truly belong in services, or having way too many event handlers than are needed to accomplish the task at hand. The best way to avoid this is to stick to your guns in design and development. Make your project stakeholders understand that good code must not just work, it needs to be both well-written and maintainable as well. A clear separation between functionality layers – keeping DOM manipulation in directives, ensuring the display layer focuses exclusively on data display, and so on – helps to not only reduce bugs in the codebase, but to also ease future extensions of the developed functionality. Mistake 4 – Ignoring the Tools Available One of the most frustrating things for nearly any person trying to help an aspiring programmer is when they fail to make adequate use of the tools available. Chrome and Firefox, for example, include a full-featured development suite that covers profiling, debugging, and error output. This allows a developer to develop more iteratively in the browser, finding and troubleshooting errors very quickly. A common example of this is the console log – Angular errors are often printed on the console log, with more than enough information to provide a start to the troubleshooting process. This is particularly an issue during the learning process, when finding your way through Angular code for the first time. It can be far too easy to rely upon asking questions and having someone give you answers. Thus, it should be a best practice to always check the console output before hunting for solutions – a number of seemingly complex errors boil down to a simple error reported in the browser. Mistake 5 – Non-Idiomatic Code Angular is developed with a declarative style of programming in mind. It was designed to serve as an extension of HTML, meaning that it wants to present the data based on a concrete set of rules. In other words, once the data is displayed the DOM should be changed as little as possible. Trying to approach this type of programming from a jQuery perspective – where imperative programming is used to drive DOM changes in a procedural approach – can quickly make your code a mess. While relying upon what you know can be a quick draw for a programmer looking to get something up and running quickly, Angular becomes a lot easier to use when developed along the intended paths. www.backand.com
  • 4. Conclusion The above list of common issues with Angular development is not exhaustive – far from it. However, the issues presented above are exceedingly common among neophyte Angular developers. Some are architectural in nature, and as such not necessarily Angular-specific, but quirks like scope handling in Angular can catch even seasoned developers off-guard. Keep the above in mind as you develop your code, and you’ll find yourself with a lot fewer headaches. www.backand.com Contact Information Backand Inc. info@backand.com www.backand.com