SOLVED
Good Evening,
I'm having trouble with hiding navigation sidebar using ng-if from angular. I declare the activetab on $route but it still didn't work. Here's the code.
Html:
<header ng-if="$route.current.activetab !== 'login'">
<div class="col s3">
<ul id="nav-mobile" class="side-nav fixed">
<li class="logo">
<a href="#" id="logo-container" class="brand-logo">BRAND LOGO</a>
</li>
<li>Test</li>
<li>Test</li>
<li>Test</li>
<li>Test</li>
<li>Test</li>
</ul>
</div>
$route config on app.js:
experimentApp.config(['$routeProvider', '$locationProvider', '$httpProvider',
function($routeProvider, $locationProvider, $httpProvider) {
var baseTitle = 'Experiment';
$routeProvider.when('/', {
title: baseTitle + ' - Home',
templateUrl: 'partials/home.php',
activetab: 'home'
}).when('/login', {
title: baseTitle + ' - Login',
templateUrl: 'partials/login.php',
activetab: 'login',
controller: 'LoginController'
});
}]);
Answer:
i created new controller named navigation, partitioning the html and put some code on root controller.
Navigation Controller:
experimentApp.controller('navigation',
['$scope', '$location', '$route', function($scope, $location, $route) {
$scope.navigation = function() {
if (!$scope.active('/login')) {
return 'partials/navigation.php';
}
}
}]);
$scope.active on root controller:
$scope.active = function(path) {
return $location.path().match(new RegExp(path + '.*', 'i')) != null;
}
HTML:
<header ng-controller="navigation" ng-include="navigation()"></header>
Thanks to anyone who helped.