Skip to content

Commit 87cbf9f

Browse files
committed
Remove ng:watch
Closes#143
1 parent fd6e5e3 commit 87cbf9f

4 files changed

Lines changed: 1 addition & 78 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
To migrate simply remove the call to $init() and move any code you had before $init() to the
1515
root controller.
1616
- Change API angular.compile(..) to angular.compile(element)([scope], [cloneAttachFn])
17-
17+
- remove ng:watch directives since it encourages logic in the UI.
1818

1919
<a name="0.9.11"><a/>
2020
# <angular/> 0.9.11 snow-maker (2011-02-08) #

src/directives.js

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -516,51 +516,6 @@ angularDirective("ng:submit", function(expression, element) {
516516
});
517517

518518

519-
/**
520-
* @workInProgress
521-
* @ngdoc directive
522-
* @name angular.directive.ng:watch
523-
*
524-
* @description
525-
* The `ng:watch` allows you watch a variable and then execute
526-
* an evaluation on variable change.
527-
*
528-
* @element ANY
529-
* @param {expression} expression {@link guide.expression Expression} to eval.
530-
*
531-
* @example
532-
* Notice that the counter is incremented
533-
* every time you change the text.
534-
<doc:example>
535-
<doc:source>
536-
<div ng:init="counter=0" ng:watch="name: counter = counter+1">
537-
<input type="text" name="name" value="hello"><br/>
538-
Change counter: {{counter}} Name: {{name}}
539-
</div>
540-
</doc:source>
541-
<doc:scenario>
542-
it('should check ng:watch', function(){
543-
expect(using('.doc-example-live').binding('counter')).toBe('2');
544-
using('.doc-example-live').input('name').enter('abc');
545-
expect(using('.doc-example-live').binding('counter')).toBe('3');
546-
});
547-
</doc:scenario>
548-
</doc:example>
549-
*/
550-
//TODO: delete me, since having watch in UI is logic in UI. (leftover form getangular)
551-
angularDirective("ng:watch", function(expression, element){
552-
return function(element){
553-
var self = this;
554-
parser(expression).watch()({
555-
addListener:function(watch, exp){
556-
self.$watch(watch, function(){
557-
return exp(self);
558-
}, element);
559-
}
560-
});
561-
};
562-
});
563-
564519
function ngClass(selector) {
565520
return function(expression, element){
566521
var existing = element[0].className + ' ';

test/BinderSpec.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,6 @@ describe('Binder', function(){
226226
'</ul>', sortedHtml(a.view));
227227
});
228228

229-
it('ExpandEntityTag', function(){
230-
assertEquals(
231-
'<div ng-entity="Person" ng:watch="$anchor.a:1"></div>',
232-
this.compileToHtml('<div ng-entity="Person" ng:watch="$anchor.a:1"/>'));
233-
});
234-
235229
it('DoNotOverwriteCustomAction', function(){
236230
var html = this.compileToHtml('<input type="submit" value="Save" action="foo();">');
237231
assertTrue(html.indexOf('action="foo();"') > 0 );
@@ -612,20 +606,6 @@ describe('Binder', function(){
612606
assertEquals("male", male.val());
613607
});
614608

615-
it('ItShouldListenOnRightScope', function(){
616-
var c = this.compile(
617-
'<ul ng:init="counter=0; gCounter=0" ng:watch="w:counter=counter+1">' +
618-
'<li ng:repeat="n in [1,2,4]" ng:watch="w:counter=counter+1;w:$root.gCounter=$root.gCounter+n"/></ul>');
619-
c.scope.$eval();
620-
assertEquals(1, c.scope.$get("counter"));
621-
assertEquals(7, c.scope.$get("gCounter"));
622-
623-
c.scope.$set("w", "something");
624-
c.scope.$eval();
625-
assertEquals(2, c.scope.$get("counter"));
626-
assertEquals(14, c.scope.$get("gCounter"));
627-
});
628-
629609
it('ItShouldRepeatOnHashes', function(){
630610
var x = this.compile('<ul><li ng:repeat="(k,v) in {a:0,b:1}" ng:bind=\"k + v\"></li></ul>');
631611
x.scope.$eval();

test/directivesSpec.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,6 @@ describe("directive", function(){
137137
expect(input.checked).toEqual(true);
138138
});
139139

140-
it('should ng:watch', function(){
141-
var scope = compile('<div ng:watch="i: count = count + 1" ng:init="count = 0">');
142-
scope.$eval();
143-
scope.$eval();
144-
expect(scope.$get('count')).toEqual(1);
145-
146-
scope.$set('i', 0);
147-
scope.$eval();
148-
scope.$eval();
149-
expect(scope.$get('count')).toEqual(2);
150-
});
151-
152140
describe('ng:click', function(){
153141
it('should get called on a click', function(){
154142
var scope = compile('<div ng:click="clicked = true"></div>');

0 commit comments

Comments
 (0)