0

Something has perplexed me about the transition of Angular. I feel that we are loading more and more functionality and logic into the html element vs the controller. It complicates things significantly and I am not sure why we do this.

example:

<p> You have {{dollars}} dollars </p>
<crazy-awesome-widget ng-repeat="account in accounts" info="dollars">
</crazy-awesome-widget>

<script>
angular.module('dotDemo').controller('OuterCtrl', function($scope) {
  $scope.dollars = 5;
  $scope.accounts = ["Tom", "Bobby", "Sally"];
});
angular.module('dotDemo').directive('crazyAwesomeWidget', function() {
  return {
    restrict: 'E',
    template: '<input type="text" ng-model="info" />',
    scope: {
      info: '='
    }
  };
});
</script>

To me, there is only 3 reasons to ever make changes in application structure. - Performance - Security - UI/UX

Other than that, most things are developer preference. Sure some things can be organized better and kept cleaner, but by no means to me does pumping everything into a directive, especially if its not reused.

Anyone have good explanation why we as a community have moved in this direction?

Ezos
  • 107
  • 1
  • 12
  • 1
    Don't quite understand why anyone would do that with the example you gave, but ignoring that, it seems developers are more and more moving to modularizing *everything* with the hope that one day it would be reused, however more often than not, the next dev that comes along will rebuild it anyway rather than trying to figure out where to find the code for some obscure module. – Kevin B Nov 17 '15 at 22:18
  • well, that isn't exactly a spectacular example of a directive there... It's hard to understand what you are asking with this, because it mostly looks like a contrived sample to prove some rant. – Claies Nov 17 '15 at 22:20
  • It's supposed to be a lot different in Angular 2 - check into it. – serraosays Nov 17 '15 at 22:46
  • Not ranting but trying to gain understanding of "why?" - I am looking for someone to give me that "ah ha" moment that I seem to have not gotten yet from using pure directives for everything. The example is not the best, but is an example, I am currently in working environment where everything is directives, even

    are converted to directives.

    – Ezos Nov 18 '15 at 18:58

0 Answers0