Web Development with Blazor by Jimmy Engström

Web Development with Blazor by Jimmy Engström

Author:Jimmy Engström
Language: eng
Format: epub
Publisher: Packt Publishing Pvt Ltd
Published: 2021-06-18T00:00:00+00:00


Run the project and navigate to /admin/tags.

Try to add, edit, and delete a tag as shown in Figure 6.2:

Figure 6.2 – The edit tag view

Now we only have two things left: we need ways to list and edit blog posts.

Listing and editing blog posts

Let's start with listing and editing blog posts:

Right-click on the Pages/Admin folder, select Add | Razor component, and name the component BlogPostList.razor.

At the top of the BlogPostList.razor file, replace <h3>BlogPostList</h3> with the following code:@page "/admin/blogposts"

@inject IMyBlogApi api

<a href="/admin/blogposts/new">New blog post</a>

<ul>

<Virtualize ItemsProvider="LoadPosts" Context="p">

<li>@p.PublishDate

<a href="/admin/blogposts/@p.Id">@p.Title</a>

</li>

</Virtualize>

</ul>

We added a page directive, injected our API, and listed the blog posts using the Virtualize component.

We also linked the posts to a URL with the Id instance of the blog post.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.