Parallax Component - Materializecss and Angularjs

Asked

Viewed 238 times

0

I am using in a page, Angularjs and materializecss. I am doing the angular SPA scheme, in my index.html I have a menu and a footer and among them have the tag <div ng-view></div>

I use $routeProvider to direct to the page. There’s the problem. In my route '/' I have a Parallax (component of materialize css), this component should be started according to the materialize documentation, but I start in a script on the page and does not work, like this:

init.js

(function($){
  $(function(){
    console.log('passa');
    $('.button-collapse').sideNav();
    $('.parallax').parallax();

  }); // end of document ready
})(jQuery); // end of jQuery name space

and make the call normally on the index.

index.html
<script src="/assets/js/init.js"></script>

This way it works if Parallax is in my main html, but as it is in another html and this being called by the angular is not being started and does not work.

I tried to put in the page controller and the following error occurs:

Typeerror: Cannot read Property 'indexof' of Undefined at r.fn.load

Has anyone ever been through something like this? I’m a beginner in Web programming... Thanks in advance!

1 answer

0

Problem has been solved by initiating this way

    $(document).ready(function(){
      $('.button-collapse').sideNav();
      $('.parallax').parallax();
    });

In the controller of the page that has these components.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.