feat(platform-browser) add LinkDefinition and Link service#34606
feat(platform-browser) add LinkDefinition and Link service#34606d-koppenhagen wants to merge 10 commits into
Conversation
Link service and LinkDefinitionLink service and LinkDefinition
Link service and LinkDefinition|
My circle CI tests are failing because of the following error: Any clue how to fix this? |
67d126a to
62adb94
Compare
c4eef3d to
ca896a9
Compare
run |
mhevery
left a comment
There was a problem hiding this comment.
This seems to be a new feature. Please add:
- Description of a problem this is solving.
- Developer documentation so that someone can discover it and use it.
Without the above we don't really know what we are reviewing and it can't be merged since the developers will not know how to use it.
...by running `yarn bazel run //tools/public_api_guard:platform-browser_api.accept`
ca896a9 to
ac43446
Compare
|
@mhevery thanks for the reply. As it's my first PR, I may not that experiences in what to add at which place.
|
|
The One example for using the service is to add canonical URLs dynamically to your app. Without the service the implementation for doing this would look like this for an angular developer: import { Injectable, Inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';
@Injectable({
providedIn: 'root',
})
export class LinkService {
constructor(@Inject(DOCUMENT) private dom) {}
createCanonicalURL(url: string) {
let link: HTMLLinkElement = document.querySelector('link[rel="canonical"]');
if (link) {
link.setAttribute('href', url);
} else {
link = this.dom.createElement('link');
link.setAttribute('rel', 'canonical');
this.dom.head.appendChild(link);
link.setAttribute('href', url);
}
}
}After the public import { Injectable, Inject } from '@angular/core';
import { Link } from '@angular/platform-browser';
@Injectable({
providedIn: 'root',
})
export class LinkService {
constructor(public link: Meta,) {}
createCanonicalURL(url: string) {
this.link.updateTag({ rel: 'canonical', href: url });
}
} |
|
Hello, after discussing with the team, we don't think we want to be adding new API surface to the Angular at this time. I will close it for now. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #34605 (Provide a LinkService)
What is the new behavior?
Not implemented yet.
Does this PR introduce a breaking change?