diff options
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | src/directives.js | 45 | ||||
| -rw-r--r-- | test/BinderSpec.js | 20 | ||||
| -rw-r--r-- | test/directivesSpec.js | 12 |
4 files changed, 1 insertions, 78 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index ef08e2c5..6ac2fecd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ To migrate simply remove the call to $init() and move any code you had before $init() to the root controller. - Change API angular.compile(..) to angular.compile(element)([scope], [cloneAttachFn]) - +- remove ng:watch directives since it encourages logic in the UI. <a name="0.9.11"><a/> # <angular/> 0.9.11 snow-maker (2011-02-08) # diff --git a/src/directives.js b/src/directives.js index 53601a4f..5e611571 100644 --- a/src/directives.js +++ b/src/directives.js @@ -516,51 +516,6 @@ angularDirective("ng:submit", function(expression, element) { }); -/** - * @workInProgress - * @ngdoc directive - * @name angular.directive.ng:watch - * - * @description - * The `ng:watch` allows you watch a variable and then execute - * an evaluation on variable change. - * - * @element ANY - * @param {expression} expression {@link guide.expression Expression} to eval. - * - * @example - * Notice that the counter is incremented - * every time you change the text. - <doc:example> - <doc:source> - <div ng:init="counter=0" ng:watch="name: counter = counter+1"> - <input type="text" name="name" value="hello"><br/> - Change counter: {{counter}} Name: {{name}} - </div> - </doc:source> - <doc:scenario> - it('should check ng:watch', function(){ - expect(using('.doc-example-live').binding('counter')).toBe('2'); - using('.doc-example-live').input('name').enter('abc'); - expect(using('.doc-example-live').binding('counter')).toBe('3'); - }); - </doc:scenario> - </doc:example> - */ -//TODO: delete me, since having watch in UI is logic in UI. (leftover form getangular) -angularDirective("ng:watch", function(expression, element){ - return function(element){ - var self = this; - parser(expression).watch()({ - addListener:function(watch, exp){ - self.$watch(watch, function(){ - return exp(self); - }, element); - } - }); - }; -}); - function ngClass(selector) { return function(expression, element){ var existing = element[0].className + ' '; diff --git a/test/BinderSpec.js b/test/BinderSpec.js index ce2a9d3a..80a950b0 100644 --- a/test/BinderSpec.js +++ b/test/BinderSpec.js @@ -226,12 +226,6 @@ describe('Binder', function(){ '</ul>', sortedHtml(a.view)); }); - it('ExpandEntityTag', function(){ - assertEquals( - '<div ng-entity="Person" ng:watch="$anchor.a:1"></div>', - this.compileToHtml('<div ng-entity="Person" ng:watch="$anchor.a:1"/>')); - }); - it('DoNotOverwriteCustomAction', function(){ var html = this.compileToHtml('<input type="submit" value="Save" action="foo();">'); assertTrue(html.indexOf('action="foo();"') > 0 ); @@ -612,20 +606,6 @@ describe('Binder', function(){ assertEquals("male", male.val()); }); - it('ItShouldListenOnRightScope', function(){ - var c = this.compile( - '<ul ng:init="counter=0; gCounter=0" ng:watch="w:counter=counter+1">' + - '<li ng:repeat="n in [1,2,4]" ng:watch="w:counter=counter+1;w:$root.gCounter=$root.gCounter+n"/></ul>'); - c.scope.$eval(); - assertEquals(1, c.scope.$get("counter")); - assertEquals(7, c.scope.$get("gCounter")); - - c.scope.$set("w", "something"); - c.scope.$eval(); - assertEquals(2, c.scope.$get("counter")); - assertEquals(14, c.scope.$get("gCounter")); - }); - it('ItShouldRepeatOnHashes', function(){ var x = this.compile('<ul><li ng:repeat="(k,v) in {a:0,b:1}" ng:bind=\"k + v\"></li></ul>'); x.scope.$eval(); diff --git a/test/directivesSpec.js b/test/directivesSpec.js index 2d4703a2..c02eb025 100644 --- a/test/directivesSpec.js +++ b/test/directivesSpec.js @@ -137,18 +137,6 @@ describe("directive", function(){ expect(input.checked).toEqual(true); }); - it('should ng:watch', function(){ - var scope = compile('<div ng:watch="i: count = count + 1" ng:init="count = 0">'); - scope.$eval(); - scope.$eval(); - expect(scope.$get('count')).toEqual(1); - - scope.$set('i', 0); - scope.$eval(); - scope.$eval(); - expect(scope.$get('count')).toEqual(2); - }); - describe('ng:click', function(){ it('should get called on a click', function(){ var scope = compile('<div ng:click="clicked = true"></div>'); |
