I am trying to create navigation links using the following array:
JS:
$scope.sidebarLinks = [
{
name: 'Dashboard',
state: 'dashboard',
},
{
name: 'Students',
state: 'student.list'
},
{
name: 'Organization',
children: [
{
name: 'School Profile',
state: 'schoolProfile.detail',
},
],
},
]
HTML:
<ul>
<li ui-sref-active="active" ng-repeat="x in sidebarLinks">
<a ui-sref="{{x.state}}"></a>
</li>
</ul>
Since the state of 'Organization' is undefined, the ui-sref is empty for it. And so there is error saying:
Error: Invalid state ref ''
I have found some sort of hack in the following answer:
How to achieve that "ui-sref" be conditionally executed?
Is there some sort of (hack) way to solve the problem without creating new functions or controller for this??