diff options
Diffstat (limited to 'docs/content/guide')
4 files changed, 47 insertions, 51 deletions
diff --git a/docs/content/guide/dev_guide.expressions.ngdoc b/docs/content/guide/dev_guide.expressions.ngdoc index 4df69d28..b7ecc521 100644 --- a/docs/content/guide/dev_guide.expressions.ngdoc +++ b/docs/content/guide/dev_guide.expressions.ngdoc @@ -51,14 +51,14 @@ You can try evaluating different expressions here: <doc:example> <doc:source> <script> - function Cntl2() { - this.exprs = []; - this.expr = '3*10|currency'; - this.addExp = function(expr) { + function Cntl2($scope) { + $scope.exprs = []; + $scope.expr = '3*10|currency'; + $scope.addExp = function(expr) { this.exprs.push(expr); }; - this.removeExp = function(contact) { + $scope.removeExp = function(contact) { for ( var i = 0, ii = this.exprs.length; i < ii; i++) { if (contact === this.exprs[i]) { this.exprs.splice(i, 1); @@ -101,10 +101,10 @@ the global state (a common source of subtle bugs). <doc:example> <doc:source> <script> - function Cntl1($window){ - this.name = 'World'; + function Cntl1($window, $scope){ + $scope.name = 'World'; - this.greet = function() { + $scope.greet = function() { ($window.mockWindow || $window).alert('Hello ' + this.name); } } diff --git a/docs/content/guide/dev_guide.forms.ngdoc b/docs/content/guide/dev_guide.forms.ngdoc index b4e37abd..03d0e6f9 100644 --- a/docs/content/guide/dev_guide.forms.ngdoc +++ b/docs/content/guide/dev_guide.forms.ngdoc @@ -111,10 +111,10 @@ The following example demonstrates: .ng-form {display: block;} </style> <script> - function UserFormCntl() { - this.state = /^\w\w$/; - this.zip = /^\d\d\d\d\d$/; - this.master = { + function UserFormCntl($scope) { + $scope.state = /^\w\w$/; + $scope.zip = /^\d\d\d\d\d$/; + $scope.master = { customer: 'John Smith', address:{ line1: '123 Main St.', @@ -123,28 +123,26 @@ The following example demonstrates: zip:'12345' } }; - this.cancel(); - } - UserFormCntl.prototype = { - cancel: function() { - this.form = angular.copy(this.master); - }, + $scope.cancel = function() { + $scope.form = angular.copy($scope.master); + }; - save: function() { - this.master = this.form; - this.cancel(); - }, + $scope.save = function() { + $scope.master = $scope.form; + $scope.cancel(); + }; - isCancelDisabled: function() { - return angular.equals(this.master, this.form); - }, + $scope.isCancelDisabled = function() { + return angular.equals($scope.master, $scope.form); + }; - isSaveDisabled: function() { - return this.userForm.$invalid || angular.equals(this.master, this.form); - } + $scope.isSaveDisabled = function() { + return $scope.userForm.$invalid || angular.equals($scope.master, $scope.form); + }; - }; + $scope.cancel(); + } </script> <div ng:controller="UserFormCntl"> @@ -282,15 +280,13 @@ This example shows how to implement a custom HTML editor widget in Angular. <doc:example> <doc:source> <script> - function EditorCntl() { - this.htmlContent = '<b>Hello</b> <i>World</i>!'; + function EditorCntl($scope) { + $scope.htmlContent = '<b>Hello</b> <i>World</i>!'; } - HTMLEditorWidget.$inject = ['$element', 'htmlFilter']; - function HTMLEditorWidget(element, htmlFilter) { - var self = this; - - this.$parseModel = function() { + HTMLEditorWidget.$inject = ['$element', '$scope', 'htmlFilter']; + function HTMLEditorWidget(element, scope, htmlFilter) { + scope.$parseModel = function() { // need to protect for script injection try { this.$viewValue = htmlFilter( @@ -305,13 +301,13 @@ This example shows how to implement a custom HTML editor widget in Angular. } } - this.$render = function() { + scope.$render = function() { element.html(this.$viewValue); } element.bind('keyup', function() { - self.$apply(function() { - self.$emit('$viewChange', element.html()); + scope.$apply(function() { + scope.$emit('$viewChange', element.html()); }); }); } @@ -364,13 +360,13 @@ validation. <doc:example> <doc:source> <script> - function Ctrl() { - this.input1 = ''; - this.input2 = ''; - this.input3 = 'A'; - this.input4 = false; - this.input5 = 'c'; - this.input6 = []; + function Ctrl($scope) { + $scope.input1 = ''; + $scope.input2 = ''; + $scope.input3 = 'A'; + $scope.input4 = false; + $scope.input5 = 'c'; + $scope.input6 = []; } </script> <table style="font-size:.9em;" ng:controller="Ctrl"> diff --git a/docs/content/guide/dev_guide.overview.ngdoc b/docs/content/guide/dev_guide.overview.ngdoc index 5d308167..faf40af5 100644 --- a/docs/content/guide/dev_guide.overview.ngdoc +++ b/docs/content/guide/dev_guide.overview.ngdoc @@ -43,9 +43,9 @@ easier a web developer's life can if they're using angular: <doc:example> <doc:source> <script> - function InvoiceCntl() { - this.qty = 1; - this.cost = 19.95; + function InvoiceCntl($scope) { + $scope.qty = 1; + $scope.cost = 19.95; } </script> <div ng:controller="InvoiceCntl"> diff --git a/docs/content/guide/dev_guide.templates.filters.creating_filters.ngdoc b/docs/content/guide/dev_guide.templates.filters.creating_filters.ngdoc index 98b41411..87894227 100644 --- a/docs/content/guide/dev_guide.templates.filters.creating_filters.ngdoc +++ b/docs/content/guide/dev_guide.templates.filters.creating_filters.ngdoc @@ -34,8 +34,8 @@ text upper-case and assigns color. } }); - function Ctrl() { - this.greeting = 'hello'; + function Ctrl($scope) { + $scope.greeting = 'hello'; } </script> |
