I'm doing a website with angularJS and ui-router.
My problem is that a have a custom Javascript file for my dropdown menu and other resources in my page. All works fine when i write the html directly in my index page or use PHP include to include the code in the page. But when using ui-route my Javascript code don't work with the objects inside the view and I can't figure out why.
I tried lazy loading and it failed.
heres my html code:
<body ng-app="MuRings">
<div ui-view="menu"></div>
my router code:
var app = angular.module("MuRings", ["ui.router"])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: "/",
views: {
"topContacts": { templateUrl: "views/topContacts.html"},
"menu": { templateUrl: "views/navbar.html"},
"headerTitle": { templateUrl: "views/headerTitle.html"}
}
});
$urlRouterProvider.otherwise("/");
});
im loading this navbar into the ui-view:
<nav class="nk-navbar nk-navbar-top nk-navbar-sticky nk-navbar-autohide">
<div class="container">
<div class="nk-nav-table">
<a href="index.html" class="nk-nav-logo">
<img src="assets/images/logo.png" alt="" width="90">
</a>
<ul class="nk-nav nk-nav-right hidden-md-down" data-nav-mobile="#nk-nav-mobile">
<li class="active">
<a href="index.html">Home</a>
</li>
<li class=" ">
<a href="#">Sobre o Jogo</a>
</li>
<li class=" nk-mega-item nk-drop-item">
<a href="#">Guias</a>
<div class="dropdown">
<div class="bg-image" style="background-image: url('assets/images/bg-menu.jpg')"></div>
<ul>
<li>
<ul>
<li class=" ">
<a href="element-carousels.html"> Carousels</a>
</li>
<li class=" ">
<a href="element-image-boxes.html"> Image Boxes</a>
</li>
</ul>
</li>
</ul>
</div>
</li>
<li class=" nk-drop-item">
<a href="#"> Media </a>
<ul class="dropdown">
<li class=" ">
<a href="./pages/gallery-3-col.html"> Fotos </a>
</li>
<li class=" ">
<a href="./pages/videos-2-col.html"> Videos </a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
and trying to do things like this form a JS file
// add link effect for navbar
$('.nk-navbar ul > li > a:not(.btn):not(.nk-btn):not(.no-link-effect)').addClass('link-effect-4');