Error when Registering a widget into other module

I tried the following docs for creating a widget and adding it to existing module

In this i’m trying to register a custom widget in order module

.run([
        "platformWebApp.mainMenuService",
        "platformWebApp.widgetService",
        "$state",
        function (mainMenuService, $state, widgetService) {
            //Register module in main menu
            var menuItem = {
                path: "browse/MyLoyalty",
                icon: "fa fa-cube",
                title: "MyLoyalty",
                priority: 100,
                action: function () {
                    $state.go("workspace.MyLoyaltyState");
                },
                permission: "MyLoyalty:access",
            };
            mainMenuService.addMenuItem(menuItem);

            var operationLineItemWidget = {
                controller: "MyLoyalty.customerOrderWidgetLineItemController",
                template:
                    "Modules/$(ObjectEdge.MyLoyalty)/Scripts/widgets/customerOrder-lineItem-widget.html",
            };

            widgetService.registerWidget(
                operationLineItemWidget,
                "customerOrderDetailWidgets"
            );
        },
    ]);

Please look in to source of Return modules.
It registered a new widget properly.

Second, check that you added a module dependency on VirtoCommerce.Orders im module.manifest.

vc-module-return/src/VirtoCommerce.ReturnModule.Web/module.manifest at dev · VirtoCommerce/vc-module-return (github.com)

Hey even after making changes in module.manifest i get same error

In module I have created a widget which open hello world blade, but while registering a widget I get widgetService is not function

Thank you for the source. We will check and back with comments.

Hey update my function arguments where not same from run dependencies. Thanks for quick response i was able to figure this through return module as it was small module.js. Now i can add widget to any module.

1 Like