Skip to content

Commit 8d85d31

Browse files
committed
Merge pull request johnpapa#233 from johnpapa/develop
Develop
2 parents 03b674e + 5585ed3 commit 8d85d31

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

README.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,15 +1206,17 @@ While this guide explains the *what*, *why* and *how*, I find it helpful to see
12061206
},
12071207
link: linkFunc,
12081208
controller: ExampleController,
1209-
controllerAs: 'vm'
1210-
};
1211-
1209+
controllerAs: 'vm',
1210+
bindToController: true // because the scope is isolated
1211+
};
1212+
12121213
return directive;
12131214

12141215
function linkFunc(scope, el, attr, ctrl) {
1215-
console.log('LINK: scope.max = %i', scope.max);
1216-
console.log('LINK: scope.vm.min = %i', scope.vm.min);
1217-
console.log('LINK: scope.vm.max = %i', scope.vm.max);
1216+
console.log('LINK: scope.min = %s *** should be undefined', scope.min);
1217+
console.log('LINK: scope.max = %s *** should be undefined', scope.max);
1218+
console.log('LINK: scope.vm.min = %s', scope.vm.min);
1219+
console.log('LINK: scope.vm.max = %s', scope.vm.max);
12181220
}
12191221
}
12201222

@@ -1224,16 +1226,17 @@ While this guide explains the *what*, *why* and *how*, I find it helpful to see
12241226
// Injecting $scope just for comparison
12251227
var vm = this;
12261228

1227-
vm.min = 3;
1228-
vm.max = $scope.max;
1229-
console.log('CTRL: $scope.max = %i', $scope.max);
1230-
console.log('CTRL: vm.min = %i', vm.min);
1231-
console.log('CTRL: vm.max = %i', vm.max);
1229+
vm.min = 3;
1230+
1231+
console.log('CTRL: $scope.vm.min = %s', $scope.vm.min);
1232+
console.log('CTRL: $scope.vm.max = %s', $scope.vm.max);
1233+
console.log('CTRL: vm.min = %s', vm.min);
1234+
console.log('CTRL: vm.max = %s', vm.max);
12321235
}
12331236
```
12341237
12351238
```html
1236-
/* example.directive.html */
1239+
<!-- example.directive.html -->
12371240
<div>hello world</div>
12381241
<div>max={{vm.max}}<input ng-model="vm.max"/></div>
12391242
<div>min={{vm.min}}<input ng-model="vm.min"/></div>
@@ -2382,6 +2385,7 @@ Unit testing helps maintain clean code, as such I included some of my recommenda
23822385
23832386
*Why?*: Placing them side-by-side makes it easy to find them and easy to move them with the source code if you move the source.
23842387
2388+
*Why?*: Having the spec nearby makes it easier for the source code reader to learn how the component is supposed to be used and to discover its known limitations.
23852389
23862390
*Why?*: Separating specs so they are not in a distributed build is easy with grunt or gulp.
23872391

0 commit comments

Comments
 (0)