mirror of https://github.com/abpframework/abp.git
6 changed files with 27 additions and 36 deletions
@ -1,4 +1,5 @@ |
|||
<div class="my-simple-widget"> |
|||
@model DashboardDemo.Web.Pages.Components.MySimpleWidget.MySimpleWidgetViewModel |
|||
<div class="my-simple-widget"> |
|||
<h2>My Simple Widget</h2> |
|||
<p>This is a simple widget!</p> |
|||
<p>Hello <strong>@Model.Name</strong>! This is a simple widget!</p> |
|||
</div> |
|||
@ -1,36 +1,18 @@ |
|||
using System.Collections.Generic; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Widgets; |
|||
|
|||
namespace DashboardDemo.Web.Pages.Components.MySimpleWidget |
|||
{ |
|||
[Widget( |
|||
StyleTypes = new[] { typeof(MySimpleWidgetStyleBundleContributor) }, |
|||
ScriptTypes = new[] { typeof(MySimpleWidgetScriptBundleContributor) } |
|||
StyleFiles = new[] { "/Pages/Components/MySimpleWidget/Default.css" }, |
|||
ScriptFiles = new[] { "/Pages/Components/MySimpleWidget/Default.js" } |
|||
)] |
|||
public class MySimpleWidgetViewComponent : AbpViewComponent |
|||
{ |
|||
public IViewComponentResult Invoke() |
|||
public IViewComponentResult Invoke(string name) |
|||
{ |
|||
return View("~/Pages/Components/MySimpleWidget/Default.cshtml"); |
|||
} |
|||
} |
|||
|
|||
public class MySimpleWidgetStyleBundleContributor : BundleContributor |
|||
{ |
|||
public override void ConfigureBundle(BundleConfigurationContext context) |
|||
{ |
|||
context.Files.AddIfNotContains("/Pages/Components/MySimpleWidget/Default.css"); |
|||
} |
|||
} |
|||
|
|||
public class MySimpleWidgetScriptBundleContributor : BundleContributor |
|||
{ |
|||
public override void ConfigureBundle(BundleConfigurationContext context) |
|||
{ |
|||
context.Files.AddIfNotContains("/Pages/Components/MySimpleWidget/Default.js"); |
|||
return View(new MySimpleWidgetViewModel { Name = name }); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace DashboardDemo.Web.Pages.Components.MySimpleWidget |
|||
{ |
|||
public class MySimpleWidgetViewModel |
|||
{ |
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -1,9 +1,10 @@ |
|||
@page |
|||
@using DashboardDemo.Web.Pages.Components.MySimpleWidget |
|||
@model DashboardDemo.Web.Pages.MyWidgetsModel |
|||
|
|||
@await Component.InvokeAsync(typeof(MySimpleWidgetViewComponent)) |
|||
<hr /> |
|||
@await Component.InvokeAsync("MySimpleWidget") |
|||
@* Example usage by widget name *@ |
|||
@await Component.InvokeAsync("MySimpleWidget", new { name = "John" }) |
|||
|
|||
<hr /> |
|||
<vc:my-custom-name-widget></vc:my-custom-name-widget> |
|||
|
|||
@* Example usage by widget type *@ |
|||
@await Component.InvokeAsync("MySimpleWidget", new { name = "Mete" }) |
|||
Loading…
Reference in new issue