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?
are converted to directives.
– Ezos Nov 18 '15 at 18:58