CodeSOD: A Little Obtuse

This post was originally published on this site

The Daily WTF

AngularJS, (not to be confused with Angular, its successor project and ostensible replacement) made some… interesting design choices. Controllers existed in a tree, mapped to the DOM, and were glued together by a special object called $scope. You would store your data in the $scope, and depending on exactly how you did it, that data could be accessible at various levels within the tree. $scope also doubled as an event bus, so controllers could send messages up and down the tree as needed.

In short, there’s a reason why AngularJS fell out of favor.

Still, during the era when AngularJS was the new trend, David‘s co-workers wanted to switch to using AngularJS. Unfortunately, they didn’t know AngularJS, and only knew jQuery, so this snippet demonstrates their approach to building AngularJS applications:

<div ng-controller=”myController” id=”unique_abc”>{{data}}</div> function myController($scope){ $scope.data = “static data”; $(“#unique_abc”).jQueryPlugin(); }

The HTML block attaches an Angular

To read the full article click on the 'post' link at the top.