javascript - Materializecss dropdown menu not working with AngularJS -


i'm developing web app using materializecss , angularjs front-end, problem dropdown menu component of materialize doesn't work me.

here's example dropdown on site

$( document ).ready(function(){      $(".dropdown-button").dropdown();  });
<!-- dropdown structure -->  <ul id="dropdown1" class="dropdown-content">    <li><a href="#!">one</a></li>    <li><a href="#!">two</a></li>    <li class="divider"></li>    <li><a href="#!">three</a></li>  </ul>  <nav>    <div class="nav-wrapper">      <a href="#!" class="brand-logo">logo</a>      <ul class="right hide-on-med-and-down">        <li><a href="sass.html">sass</a></li>        <li><a href="components.html">components</a></li>        <!-- dropdown trigger -->        <li><a class="dropdown-button" href="#!" data-activates="dropdown1">dropdown<i class="mdi-navigation-arrow-drop-down right"></i></a></li>      </ul>    </div>  </nav>

in site work in mine doesn't , i'm guessing has href="#!" part of dropdown button because maybe angularjs trying map route or something

if problem how can make angularjs ignore of hrefs? because in order dropdowns , modals need href="#!", or if not, what's problem, , how fix it?

i tried removing href or changing href="", didn't work.

be careful mixing frameworks, can, , have unexpected effects. showing , hiding elements, here simple example of how hide, show, or toggle element.

(demo)

html

<a href="javascript:void()" data-show="hidden">show</a> <a href="javascript:void()" data-hide="hidden">hide</a> <a href="javascript:void()" data-toggle="hidden">toggle</a> <div id="hidden"><!-- can type of element -->     <!-- in here --> </div> 

css

#hidden {     display: none; } 

javascript

$("[data-show]").on("click", function () {     $("#" + $(this).attr("data-show")).css("display", "initial"); }); $("[data-hide]").on("click", function () {     $("#" + $(this).attr("data-hide")).css("display", "none"); }); $("[data-toggle]").on("click", function () {     var target = $("#" + $(this).attr("data-toggle"));     if (target.css("display") === "none") {         target.css("display", "initial");     } else {         target.css("display", "none");     } }); 

i used jquery here because used jquery in script, can done in pure javascript well. make sure put javascript after dom, otherwise wrap script in document.onload handler.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -