Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($rootScope): remove support for a watch listener to be a string #8190

Closed

Conversation

rodyhaddad
Copy link
Contributor

BREAKING CHANGE:

Previously, it was possible for a listener passed to $watch
to be a string, interpreted as an angular expresison. This is no longer supported.
The listener now has to be a function.
Passing a listener to $watch is still optional.

@mary-poppins
Copy link

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#8190)

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@caitp
Copy link
Contributor

caitp commented Jul 14, 2014

This is fine to me --- I was confused for a moment because I read this description as saying "EXPRESSIONS CAN NO LONGER BE WATCHED".

+1 for this CL

@lord2800
Copy link

I was also confused by this at first as well--then I read the changes to the tests, and it made sense.

@Narretz
Copy link
Contributor

Narretz commented Jul 14, 2014

I was confused there for a moment, too. Can you please add the complimentary before / after part to the BREAKING CHANGE notice?

BREAKING CHANGE:

Previously, it was possible for an action passed to $watch
to be a string, interpreted as an angular expresison. This is no longer supported.
The action now has to be a function.
Passing an action to $watch is still optional.

Before:

```js
$scope.$watch('state', ' name="" ');
```

After:

```js
$scope.$watch('state', function () {
  $scope.name = "";
});
```
@rodyhaddad
Copy link
Contributor Author

Igor proposed renaming watch listener to watch action, so I did that.

Also added a before / after part to the commit message

ckknight pushed a commit to ckknight/angular.js that referenced this pull request Jul 16, 2014
BREAKING CHANGE:

Previously, it was possible for an action passed to $watch
to be a string, interpreted as an angular expresison. This is no longer supported.
The action now has to be a function.
Passing an action to $watch is still optional.

Before:

```js
$scope.$watch('state', ' name="" ');
```

After:

```js
$scope.$watch('state', function () {
  $scope.name = "";
});
```

Closes angular#8190
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants