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

docs($compile): remove a mention of preassigning bindings in controllers #15870

Merged
merged 1 commit into from
Mar 29, 2017

Conversation

mgol
Copy link
Member

@mgol mgol commented Mar 29, 2017

The deprecation warning is no longer needed as the feature has been removed
in 1.7.

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Docs update.

What is the current behavior? (You can also link to an open issue here)
Preassigning bindings to controllers is described as deprecated but still working. This feature has been removed so the warning is no longer needed.

What is the new behavior (if this is a feature change)?
N/A

Does this PR introduce a breaking change?
No.

Please check if the PR fulfills these requirements

Other information:

The deprecation warning is no longer needed as the feature has been removed
in 1.7.
@mgol mgol added this to the 1.7.0 milestone Mar 29, 2017
mgol added a commit that referenced this pull request Mar 29, 2017
The deprecation warning claimed the bindings are preassigned in controllers
by default which is not the case in 1.6.

Ref #15870
mgol referenced this pull request Mar 29, 2017
Fixes #15350
Closes #15352

BREAKING CHANGE: Previously, $compileProvider.preAssignBindingsEnabled was
set to true by default. This means bindings were pre-assigned in component
constructors. In Angular 1.5+ the place to put the initialization logic
relying on bindings being present is the controller $onInit method.

To migrate follow the example below:

Before:

```js
angular.module('myApp', [])
  .component('myComponent', {
    bindings: {value: '<'},
    controller: function() {
      this.doubleValue = this.value * 2;
    }
  });
```

After:
```js
angular.module('myApp', [])
  .component('myComponent', {
    bindings: {value: '<'},
    controller: function() {
      this.$onInit = function() {
        this.doubleValue = this.value * 2;
      };
    }
  });
```

If you don't have time to migrate the code at the moment, you can flip the
setting back to true:
```js
angular.module('myApp', [])
  .config(function($compileProvider) {
    $compileProvider.preAssignBindingsEnabled(false);
  })
  .component('myComponent', {
    bindings: {value: '<'},
    controller: function() {
      this.doubleValue = this.value * 2;
    }
  });
```
Don't do this if you're writing a library, though, as you shouldn't change
global configuration then.
Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mgol mgol merged commit 1e841a8 into angular:master Mar 29, 2017
@mgol mgol deleted the outdated-doc branch March 29, 2017 12:15
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.

3 participants