Adeel Khan Adeel Khan - 1 year ago 62
AngularJS Question

navigation does not work with ng-if condtion

hi i need help from you guys, when i add in ul with ng-if condition navigation does not work, how to solve this please help

<nav id="menu" class="nav-main" role="navigation">
<ul class="nav nav-main" ng-if=" $ctrl.getCurrentUser().user_type == 'Customer'">
<li class="">
<a href="/dashboard">
<i class="fa fa-home" aria-hidden="true"></i>
<li class="nav-parent">
<a href="#">
<i class="fa fa-table" aria-hidden="true"></i>
<ul class="nav nav-children">
<li><a href="/addjob">Add New Job</a></li>

<ul class="nav nav-main" ng-if=" $ctrl.getCurrentUser().user_type == 'Customer'">

Answer Source

I had same problem, below solution worked for me.

Define in your controller

$scope.user = $this->getCurrentUser();

And use ng-show instant of ng-if

<ul class="nav nav-main" ng-show=" user.user_type == 'Customer'">

Please try this if it works for you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download