@@ -50,9 +50,9 @@ the method from your view. If you want to `eval()` an Angular expression yoursel
50
50
51
51
You can try evaluating different expressions here:
52
52
53
- <example>
53
+ <example module="expressionExample" >
54
54
<file name="index.html">
55
- <div ng-controller="Cntl2 " class="expressions">
55
+ <div ng-controller="ExampleController " class="expressions">
56
56
Expression:
57
57
<input type='text' ng-model="expr" size="80"/>
58
58
<button ng-click="addExp(expr)">Evaluate</button>
@@ -66,17 +66,18 @@ You can try evaluating different expressions here:
66
66
</file>
67
67
68
68
<file name="script.js">
69
- function Cntl2($scope) {
70
- var exprs = $scope.exprs = [];
71
- $scope.expr = '3*10|currency';
72
- $scope.addExp = function(expr) {
73
- exprs.push(expr);
74
- };
75
-
76
- $scope.removeExp = function(index) {
77
- exprs.splice(index, 1);
78
- };
79
- }
69
+ angular.module('expressionExample', [])
70
+ .controller('ExampleController', ['$scope', function($scope) {
71
+ var exprs = $scope.exprs = [];
72
+ $scope.expr = '3*10|currency';
73
+ $scope.addExp = function(expr) {
74
+ exprs.push(expr);
75
+ };
76
+
77
+ $scope.removeExp = function(index) {
78
+ exprs.splice(index, 1);
79
+ };
80
+ }]);
80
81
</file>
81
82
82
83
<file name="protractor.js" type="protractor">
@@ -101,23 +102,24 @@ This restriction is intentional. It prevents accidental access to the global sta
101
102
Instead use services like `$window` and `$location` in functions called from expressions. Such services
102
103
provide mockable access to globals.
103
104
104
- <example>
105
+ <example module="expressionExample" >
105
106
<file name="index.html">
106
- <div class="example2" ng-controller="Cntl1 ">
107
+ <div class="example2" ng-controller="ExampleController ">
107
108
Name: <input ng-model="name" type="text"/>
108
109
<button ng-click="greet()">Greet</button>
109
110
<button ng-click="window.alert('Should not see me')">Won't greet</button>
110
111
</div>
111
112
</file>
112
113
113
114
<file name="script.js">
114
- function Cntl1($window, $scope){
115
- $scope.name = 'World';
115
+ angular.module('expressionExample', [])
116
+ .controller('ExampleController', ['$window', '$scope', function($window, $scope) {
117
+ $scope.name = 'World';
116
118
117
- $scope.greet = function() {
118
- $window.alert('Hello ' + $scope.name);
119
- };
120
- }
119
+ $scope.greet = function() {
120
+ $window.alert('Hello ' + $scope.name);
121
+ };
122
+ }]);
121
123
</file>
122
124
123
125
<file name="protractor.js" type="protractor">
0 commit comments