Skip to content

docs: Use ngOnInit to fetch data from services in the Getting Started guide - #32273

Closed
bampakoa wants to merge 1 commit into
angular:masterfrom
bampakoa:getting-started
Closed

bampakoa wants to merge 1 commit into
angular:masterfrom
bampakoa:getting-started

Conversation

@bampakoa

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #32048

What is the new behavior?

Data services are queried inside ngOnInit interface implementation of components

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@kapunahelewong

@bampakoa
bampakoa requested a review from a team August 22, 2019 17:54
@ngbot ngbot Bot added this to the needsTriage milestone Aug 22, 2019
@kapunahelewong

Copy link
Copy Markdown
Contributor

Thank you, @bampakoa. I thought you meant to call methods from within ngOnInit(). Could you put that logic in a separate method and then call that method in the ngOnInit()? Like:

  ngOnInit() {
    setItems();
  }	  

  setItems() {
    this.items = this.cartService.getItems();
  }

This is a point I've been corrected on before (so it has stayed in my mind!). What do you think?

@bampakoa

Copy link
Copy Markdown
Contributor Author

@kapunahelewong you are right. This is also the way that I follow in my projects. But isn't it too complicated for a Getting Started guide? I mean the purpose is to show them the proper way of calling services in a component. This looks to be more of a coding style as in Angular Style Guide.

@kapunahelewong

Copy link
Copy Markdown
Contributor

You're right, @bampakoa. I looked more closely and the Getting Started has logic in the ngOnInit() in routing. Never mind what I said! :)

@mary-poppins

Copy link
Copy Markdown

You can preview c196b19 at https://pr32273-c196b19.ngbuilds.io/.

@kapunahelewong kapunahelewong added target: patch This PR is targeted for the next patch release and removed aio: preview labels Aug 26, 2019
@kapunahelewong

Copy link
Copy Markdown
Contributor

Hey @bampakoa, this looks good. Would you rebase to see if we could get that test passing?

@kapunahelewong kapunahelewong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thank you @bampakoa!!

@kapunahelewong

Copy link
Copy Markdown
Contributor

Caretaker, this is a docs-only change. Thank you!

@kapunahelewong kapunahelewong added action: merge The PR is ready for merge by the caretaker and removed action: merge The PR is ready for merge by the caretaker labels Aug 26, 2019

@gkalpak gkalpak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thx, @bampakoa 🎉
Can you, please, change the commit message to docs: ... (we have deprecated the aio scope) 🙏

@gkalpak gkalpak added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Aug 26, 2019
@bampakoa

Copy link
Copy Markdown
Contributor Author

@gkalpak sure. Bear in mind that it still appears in the list of suggested scopes during commit 😉

… guide

Call data services inside ngOnInit interface implementation of components.

closes #32048
@gkalpak

gkalpak commented Aug 27, 2019

Copy link
Copy Markdown
Member

Bear in mind that it still appears in the list of suggested scopes during commit

That doesn't sound right. Where exactly does it appear?

@gkalpak gkalpak changed the title docs(aio): Use ngOnInit to fetch data from services in the Getting Started guide docs: Use ngOnInit to fetch data from services in the Getting Started guide Aug 27, 2019
@gkalpak gkalpak added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Aug 27, 2019
@gkalpak

gkalpak commented Aug 27, 2019

Copy link
Copy Markdown
Member

merge-assistance: Global approval for this docs-only change.

@bampakoa

Copy link
Copy Markdown
Contributor Author

@gkalpak When I tried to commit my change initially through Visual Studio Code, I got a notification (correctly) that my commit message does not follow the guidelines of the repository. It specifically suggested me a list of scopes where aio was included.

After a search I think that it is due to this

@gkalpak

gkalpak commented Aug 27, 2019

Copy link
Copy Markdown
Member

This is a custom config file that VSCode should have no idea about 😁
Can you look into where that notification came from? Was it a VSCode extension?

@bampakoa

Copy link
Copy Markdown
Contributor Author

It came from the Git output window of the VSCode when I tried to commit. I thought that commit-message.json file is parsed every time you are trying to commit. Isn't it?

@gkalpak

gkalpak commented Aug 27, 2019 •

Copy link
Copy Markdown
Member

Oh, it is the commitmsg git hook. Yes, you are right. That's where the error message comes from 😁
We have kept it there, because there were in-flights PRs that used the aio scope at the time. I think it is safe to remove it from the list of valid scopes now (it's been a while).

EDIT: See #32341.

gkalpak added a commit to gkalpak/angular that referenced this pull request Aug 27, 2019
The `aio` commit message scope was renamed to `docs-infra` (which is
more descriptive) in angular#24295. Although it has been removed from the
documentation, the legacy `aio` scope was kept in the [list of valid
scopes][1] to cater for in-flight PRs that already used it. As a result,
it still shows up as a recommended, valid scope in the error message
shown when commit message validation fails during `git commit`. This is
misleading, especially for new contributors.

Since we have been "manually" discouraging people from using `aio`,
there should be no open PRs by now (and if there are, they should be
changed to `docs-infra`), so it is safe to remove it from the list of
allowed scopes.

Related discussion:
angular#32273 (review)

[1]: https://github.com/angular/angular/blob/3df54be9e/tools/validate-commit-message/commit-message.json#L16
atscott pushed a commit that referenced this pull request Aug 27, 2019
The `aio` commit message scope was renamed to `docs-infra` (which is
more descriptive) in #24295. Although it has been removed from the
documentation, the legacy `aio` scope was kept in the [list of valid
scopes][1] to cater for in-flight PRs that already used it. As a result,
it still shows up as a recommended, valid scope in the error message
shown when commit message validation fails during `git commit`. This is
misleading, especially for new contributors.

Since we have been "manually" discouraging people from using `aio`,
there should be no open PRs by now (and if there are, they should be
changed to `docs-infra`), so it is safe to remove it from the list of
allowed scopes.

Related discussion:
#32273 (review)

[1]: https://github.com/angular/angular/blob/3df54be9e/tools/validate-commit-message/commit-message.json#L16

PR Close #32341
atscott pushed a commit that referenced this pull request Aug 27, 2019
The `aio` commit message scope was renamed to `docs-infra` (which is
more descriptive) in #24295. Although it has been removed from the
documentation, the legacy `aio` scope was kept in the [list of valid
scopes][1] to cater for in-flight PRs that already used it. As a result,
it still shows up as a recommended, valid scope in the error message
shown when commit message validation fails during `git commit`. This is
misleading, especially for new contributors.

Since we have been "manually" discouraging people from using `aio`,
there should be no open PRs by now (and if there are, they should be
changed to `docs-infra`), so it is safe to remove it from the list of
allowed scopes.

Related discussion:
#32273 (review)

[1]: https://github.com/angular/angular/blob/3df54be9e/tools/validate-commit-message/commit-message.json#L16

PR Close #32341
atscott pushed a commit that referenced this pull request Aug 27, 2019
… guide (#32273)

Call data services inside ngOnInit interface implementation of components.

closes #32048

PR Close #32273
@atscott atscott closed this in 55eaa5f Aug 27, 2019
@bampakoa
bampakoa deleted the getting-started branch August 27, 2019 16:24
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
The `aio` commit message scope was renamed to `docs-infra` (which is
more descriptive) in angular#24295. Although it has been removed from the
documentation, the legacy `aio` scope was kept in the [list of valid
scopes][1] to cater for in-flight PRs that already used it. As a result,
it still shows up as a recommended, valid scope in the error message
shown when commit message validation fails during `git commit`. This is
misleading, especially for new contributors.

Since we have been "manually" discouraging people from using `aio`,
there should be no open PRs by now (and if there are, they should be
changed to `docs-infra`), so it is safe to remove it from the list of
allowed scopes.

Related discussion:
angular#32273 (review)

[1]: https://github.com/angular/angular/blob/3df54be9e/tools/validate-commit-message/commit-message.json#L16

PR Close angular#32341
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
… guide (angular#32273)

Call data services inside ngOnInit interface implementation of components.

closes angular#32048

PR Close angular#32273
@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 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes effort1: hours merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note risk: low target: patch This PR is targeted for the next patch release type: bug/fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants