/ mozey.co / blog

angular donts

March 1, 2016

🔗 List of practises that make angular code fragile and unmaintainable

Some of the points listed also apply to javascript programming in general.

🔗 Adding unused variables onto the scope

Variables should only be added to the scope when it is used for template rendering or data binding.

🔗 Using scope or shared objects to communicate between controllers

Rather use event or services.

When services are used they should they should not expose shared objects, always return a copy of underlying data if simple variables are not used.

🔗 Using one data structure for multiple purposes

For example, don’t use $scope.data to render a form and then also post it to a web service. Rather create a function that extracts only the data required. The benefit is that this function then documents exactly what is intended as params.