I have defined menu items using the Navigation Provider with localization. How can I add a line break in the middle of the menu name?
Navigation Provider
public override void SetNavigation(INavigationProviderContext context)
{
context.Manager.MainMenu
.AddItem(
new MenuItemDefinition(
"Menu Item",
new LocalizableString("MenuItem", MyAppConsts.LocalizationSourceName),
url: "#/menuitem",
icon: "fa fa-clipboard"
)
);
}
My Localization Source File
<?xml version="1.0" encoding="utf-8" ?>
<localizationDictionary culture="en">
<texts>
<text name="MenuItem" value="Menu Item" />
</texts>
</localizationDictionary>
cshtml file where the menu is created
<div class="sidebar-inner">
<nav>
<ul class="nav nav-sidebar">
<li ng-repeat="menuItem in vm.menu.items" ng-class="{active: vm.currentMenuName == menuItem.name}" class="nav-parent">
<a ng-if="!menuItem.items.length" ng-href="{{menuItem.url}}"><i class="{{menuItem.icon}}" ng-if="menuItem.icon"></i><span>{{menuItem.displayName}}</span><span class="fa arrow"></span></a>
<a ng-if="menuItem.items.length" href="" ><i class="{{menuItem.icon}}" ng-if="menuItem.icon"></i><span>{{menuItem.displayName}}</span><span class="fa arrow"></span></a>
<ul ng-if="menuItem.items.length" class="children collapse">
<li ng-repeat="menuSubItem in menuItem.items">
<a ng-href="{{menuSubItem.url}}"><span>{{menuSubItem.displayName}}</span></a>
</li>
</ul>
</li>
</ul>
</nav>
</div>
I want it shown like
Menu
Item
Not like this
Menu Item
Thank you in advance.
I have figured it out using string split. In the XML source I have added a '$' where I want to break the menu name into two lines.
<texts>
<text name="MenuItem1" value="Long$Name" />
<text name="MenuItem2" value="Short Name" />
</texts>
Then I used string split to break the menu display name into two and displayed it in two lines with
tag.
<a ng-if="!menuItem.items.length" ng-href="{{menuItem.url}}">
<i class="{{menuItem.icon}}" ng-if="menuItem.icon"></i>
<span>
{{menuItem.displayName.split('$')[0]}} <br> {{menuItem.displayName.split('$')[1]}}
</span><span class="fa arrow"></span>
</a>