@@ -21,20 +21,22 @@ <h1> Angular Best Practices </h1>
21
21
< div ng-controller ="bestPractices ">
22
22
< div id ="whichBestPractices ">
23
23
Show Best Practices For:
24
- < form id ="selectKind " action =" ">
24
+ < div id ="selectKind ">
25
25
< input type ="checkbox " id ="controllers " onclick ="changeList() "> Controllers</ input >
26
26
< input type ="checkbox " id ="directives " onclick ="changeList() " checked > Directives</ input >
27
27
< input type ="checkbox " id ="DOM " onclick ="changeList() "> DOM</ input >
28
28
< input type ="checkbox " id ="events " onclick ="changeList() "> Events</ input >
29
29
< input type ="checkbox " id ="interpolation " onclick ="changeList() "> Interpolation</ input >
30
30
< input type ="checkbox " id ="modules " ng-click ="changeList() "> Modules</ input >
31
- </ form >
32
-
31
+ </ div >
33
32
</ div >
34
33
35
34
< table id ="bestPracticesList ">
36
35
</ table >
37
36
37
+ < div ng-controller ="Controller ">
38
+ < div our-visitors info ="erin "> </ div >
39
+ </ div >
38
40
< ul id ="contributors ">
39
41
< li ng-reapet ="contributor in contributors ">
40
42
{{contributor.name}}
@@ -45,9 +47,7 @@ <h1> Angular Best Practices </h1>
45
47
< script src ="../dist/hint.js "> </ script >
46
48
< script >
47
49
angular . module ( 'bpAppModule' , [ ] ) ;
48
- angular . module ( 'AppModule2' , [ ] ) ;
49
- angular . module ( 'AppModule2' , [ ] ) .
50
- controller ( 'bestPractices' , [ '$scope' , function ( $scope ) {
50
+ function bestPractices ( $scope ) {
51
51
var bestPractices = {
52
52
'controllers' : [ 'Do not use global controllers. Define controllers ' +
53
53
'on modules.' , 'Name controllers with UpperCamelCase.' , 'Name controllers with the ' +
@@ -86,7 +86,24 @@ <h1> Angular Best Practices </h1>
86
86
}
87
87
}
88
88
$scope . contributors = [ 'Me' , 'You' ] ;
89
- } ] ) ;
89
+ }
90
+
91
+ angular . module ( 'AppModule2' , [ ] ) . controller ( 'Controller' , [ '$scope' , function ( $scope ) {
92
+ $scope . erin = {
93
+ name : 'Erin' ,
94
+ bestPractice : 'Do not manipulate the DOM from within Angular Controllers.'
95
+ } ;
96
+ } ] ) ;
97
+ angular . module ( 'AppModule2' , [ ] ) . directive ( 'OurVisitors' , function ( ) {
98
+ return {
99
+ restrict : 'A' ,
100
+ template : '<br>Site Visitors:<br>Name: {{visitor.name}}. Favorite Best Practice: {{visitor.bestPractice}}' ,
101
+ scope : {
102
+ visitor : '=info'
103
+ } ,
104
+ replace : true
105
+ } ;
106
+ } ) ;
90
107
</ script >
91
108
</ body >
92
109
0 commit comments