Skip to content

Conversation

guardrex
Copy link
Collaborator

@guardrex guardrex commented Sep 24, 2018

Fixes #8553

cc: @spottedmahn

@guardrex
Copy link
Collaborator Author

Note for the record that PriorityListViewComponent doesn't work. It also doesn't work with [ViewComponent(Name = "PriorityList")]. Therefore, it's specific for the method name in this case. Let me know if you feel that I need to surface this. It doesn't really jive with what the topic states earlier about specifying a VC.

@guardrex guardrex requested a review from pranavkm September 24, 2018 19:54
Copy link
Contributor

@pranavkm pranavkm left a comment

Choose a reason for hiding this comment

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

Looks good

The view component is invoked in a Razor file (for example, *Views/Home/Index.cshtml*) with:

```cshtml
@await Component.InvokeAsync(nameof(PriorityList), new { maxPriority = 4, isDone = true })
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to show the VCTagHelper as an example here? It hides the fact it's going async

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes ... I'll do that ... and I'll say either do it this way or that way.

@guardrex
Copy link
Collaborator Author

@pranavkm Updates made.

@guardrex guardrex requested a review from scottaddie September 24, 2018 20:39
```

Note: In order to use a View Component as a Tag Helper, you must register the assembly containing the View Component using the `@addTagHelper` directive. For example, if your View Component is in an assembly called "MyWebApp", add the following directive to the `_ViewImports.cshtml` file:
Note: In order to use a View Component as a Tag Helper, you must register the assembly containing the View Component using the `@addTagHelper` directive. For example, if your view component is in an assembly called `MyWebApp`, add the following directive to the `_ViewImports.cshtml` file:
Copy link
Member

Choose a reason for hiding this comment

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

  • In order
  • you must
  • Let's be consistent all throughout with the casing of "view component".
  • Italicize the file name.
  • While you're in the file, make the Invoking a view component as a Tag Helper section display ONLY for 1.1+.

Copy link
Collaborator Author

@guardrex guardrex Sep 24, 2018

Choose a reason for hiding this comment

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

Let's be consistent all throughout with the casing of "view component".

That's what I was trying to do. It was lowercase everywhere.

I'll get these on the next commit. 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I want to simplify the prep phrase + subordinate conjunction just like we did the other day on that other PR. Let's just go with "If ... blah blah blah" ... "for example" is overused and obvious.

The view component is invoked in a Razor file (for example, *Views/Home/Index.cshtml*) using one of the following approaches:

* <xref:Microsoft.AspNetCore.Mvc.IViewComponentHelper>
* [Tag Helper](xref:mvc/views/tag-helpers/intro)
Copy link
Member

Choose a reason for hiding this comment

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

Make it clear that the Tag Helper approach only works in 1.1+.

@guardrex
Copy link
Collaborator Author

oh ... one more commit coming ... stand by ...

@guardrex
Copy link
Collaborator Author

op op op ... we have it. All good. I'll merge this when the build completes.

@guardrex guardrex merged commit fdbee59 into master Sep 24, 2018
@guardrex guardrex deleted the guardrex-patch-4 branch September 24, 2018 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants