I am using Angular2 with materializecss. At the moment, I'm trying to create modal dialogs that open when a button is clicked. There is also an example in the docs https://www.npmjs.com/package/angular2-materialize .
I also use materilize-select, which works fine, so I think installation, import, etc. true.
The problem is that when I click on the modal trigger, the router resolves to the new route "localhost: 4200 / # modal1" and I am redirected to my start page.
I also tried replacing href with data-target="modal1" , but that didn't work either.
Is there any way to disable Hash-Links for the router? My other routes without hashes.
Here is an example from npm docs. I copied this part 1: 1.
<a materialize="leanModal" [materializeParams]="[{dismissible: false}]" class="waves-effect waves-light btn modal-trigger" href="#modal1">Modal</a> <div id="modal1" class="modal"> <div class="modal-content"> <h4>Modal Header</h4> <p>A bunch of text</p> </div> <div class="modal-footer"> <a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Agree</a> </div> </div>
Any help / tips appreciated!
Edit: I changed the anchor to call the function when clicked
<a materialize="leanModal" [materializeParams]="[{dismissible: false}]" class="waves-effect waves-light btn modal-trigger" (click)="openModal()>Modal</a>
which launches
$('#modal1').openModal()
But now I get an error: j.velocity is not a function
Edit 2:
Got it to open modals using jQuery instead of $. I still get the error and the application gets stuck after opening the modal.
source share