|
| 1 | +<!doctype html> |
| 2 | +<html ng-app="bpAppModule" ng-hint> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <title>Angular Best Practices</title> |
| 6 | + |
| 7 | + <link rel="stylesheet" type="text/css" href="app.css"> |
| 8 | + |
| 9 | + </head> |
| 10 | + <header> |
| 11 | + <h1> Angular Best Practices </h1> |
| 12 | + </header> |
| 13 | + <body> |
| 14 | + <div id="subtitle1"> |
| 15 | + *You'd think a best practices application would follow the best practices. |
| 16 | + </div> |
| 17 | + <div id="subtitle2"> |
| 18 | + In this case you'd be right! |
| 19 | + </div> |
| 20 | + <div ng-controller="BestPracticesController"> |
| 21 | + <div id="whichBestPractices"> |
| 22 | + Show Best Practices For: |
| 23 | + <div id="selectKind"> |
| 24 | + <span ng-repeat="type in types"> |
| 25 | + <input type="checkbox" id="{{type.name}}" ng-model="type.isChecked"> |
| 26 | + {{type.name}} |
| 27 | + </span> |
| 28 | + </div> |
| 29 | + |
| 30 | + </div> |
| 31 | + |
| 32 | + <div ng-repeat="type in types"> |
| 33 | + <table ng-show="type.isChecked"> |
| 34 | + <tr ng-repeat="practice in type.practices"> |
| 35 | + <td> |
| 36 | + {{practice}} |
| 37 | + </td> |
| 38 | + </tr> |
| 39 | + </table> |
| 40 | + </div> |
| 41 | + |
| 42 | + <ul id="contributors"> |
| 43 | + App contributors: |
| 44 | + <li ng-repeat="contributor in contributors"> |
| 45 | + {{contributor}} |
| 46 | + </li> |
| 47 | + </ul> |
| 48 | + </div> |
| 49 | + |
| 50 | + <script src="../bower_components/angular/angular.js"></script> |
| 51 | + <script src="../dist/hint.js"></script> |
| 52 | + <script> |
| 53 | + angular.module('bpAppModule', []); |
| 54 | + angular.module('bpAppModule').controller('BestPracticesController', ['$scope', function($scope) { |
| 55 | + $scope.types = [ |
| 56 | + { name: 'Controllers', practices: ['Do not use global controllers. Define controllers ' + |
| 57 | + 'on modules.', 'Name controllers with UpperCamelCase.', 'Name controllers with the ' + |
| 58 | + 'suffix "Controller".'], isChecked: false}, |
| 59 | + { name: 'Directives', practices: ['Include required attributes.', 'Follow the restrict ' + |
| 60 | + 'property', 'Do not use deprecated options like "replace".', 'Use Angular event ' + |
| 61 | + ' directives in place of HTML event attributes like "onclick".', 'Use ng-repeat ' + |
| 62 | + ' options in the correct order.', 'Use a namespace for custom directives that ' + |
| 63 | + ' uniquely identifies the directive. Use lowerCamelCase and preferably a custom ' + |
| 64 | + 'prefix unique to the scope of the application.'], isChecked: false}, |
| 65 | + { name: 'DOM', practices: ['Do not manipulate the DOM from within Angular Controllers. Use' + |
| 66 | + ' logic in the view like "ng-repeat" or "ng-show".'], isChecked: false}, |
| 67 | + { name: 'Events', practices: ['Double check that functions or variables you bind to are ' + |
| 68 | + 'defined.'], isChecked: false}, |
| 69 | + { name: 'Interpolation', practices: ['Make sure the whole variable you are interpolating' + |
| 70 | + 'is defined.'], isChecked: false}, |
| 71 | + { name: 'Modules', practices: ['Use a namespace for modules that ' + |
| 72 | + ' uniquely identifies the module. Use lowerCamelCase and preferably a custom ' + |
| 73 | + 'prefix unique to the scope of the application.', 'Do not create and load ' + |
| 74 | + 'modules that are not used.', 'Remember to load ngRoute if you are using routing.', |
| 75 | + 'Only bootstrap one module with "ng-app".'], isChecked: false} |
| 76 | + ]; |
| 77 | + |
| 78 | + $scope.contributors = ['Me', 'You']; |
| 79 | + }]); |
| 80 | + </script> |
| 81 | + </body> |
| 82 | + |
| 83 | +</html> |
0 commit comments