X Tutup
Skip to content

feat(angular1_router): allow component to bind to router#6942

Closed
petebacondarwin wants to merge 2 commits intoangular:masterfrom
petebacondarwin:bind-to-router
Closed

feat(angular1_router): allow component to bind to router#6942
petebacondarwin wants to merge 2 commits intoangular:masterfrom
petebacondarwin:bind-to-router

Conversation

@petebacondarwin
Copy link
Copy Markdown
Contributor

This PR sits on top of #6796.

In Angular 1.5 there is a new helper method for creating component directives.
See https://docs.angularjs.org/guide/component for more information about components.

These kind of directives only match the `E` element form and the previously component
router only created HTML that matched directives that matched the `A` attribute form.

This commit changes the `<ng-outlet>` directive so that it generates custom HTML
elements rather divs with custom attributes to trigger the relevant component to
appear in the DOM.

Going forward, Angular 1.5 users are encouraged to create their router components
using the following style:

```
myModule.componnet('component-name', {
  // component definition object
});
```

Closes angular/angular.js#13860
Closes angular#6076
Closes angular#5278

BREAKING CHANGE:

The component router now creates custom element HTML rather than custom attribute
HTML, in order to create a new component. So rather than

```html
<div custom-component></div>
```

it now creates

```html
<custom-component></custom-component>
```

If you defined you router components using the `directive()` helper and
specified the `restrict` properties such that element matching was not allowed,
e.g. `restrict: 'A'` then these components will no longer be instantiated
by the component router and the outlet will be empty.

The fix is to include `E` in the `restrict` property.

`restrict: 'EA'`

Note that this does not affect directives that did not specify the `restrict`
property as the default for this property is already `EA`.
@petebacondarwin petebacondarwin added type: bug/fix feature Label used to distinguish feature request from other issues action: discuss comp: router action: review The PR is still awaiting reviews from at least one requested reviewer effort1: hours labels Feb 7, 2016
@petebacondarwin
Copy link
Copy Markdown
Contributor Author

Pete to change the referenced version of AngularJS to 1.5.0

@petebacondarwin
Copy link
Copy Markdown
Contributor Author

via 0f22dce

@petebacondarwin petebacondarwin deleted the bind-to-router branch September 2, 2017 14:49
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: discuss action: review The PR is still awaiting reviews from at least one requested reviewer cla: yes effort1: hours feature Label used to distinguish feature request from other issues type: bug/fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup