jQuery slider not working in angularjs

前端 未结 1 1025
青春惊慌失措
青春惊慌失措 2021-02-11 03:58

My slider wont come up on first time navigation of the page. However when I hard refresh the page then it comes up and also if I replace the

1条回答
  •  甜味超标
    2021-02-11 04:36

    The event handler attached with jQuery(window).load will run when the page is fully loaded. However, ng-view hasn't loaded your view yet, which means

    doesn't exist.

    Move the initialization into a directive:

    myApp.directive('flexslider', function () {
    
      return {
        link: function (scope, element, attrs) {
    
          element.flexslider({
            animation: "slide"
          });
        }
      }
    });
    

    And use like this:

    Demo: http://plnkr.co/edit/aVC9fnRhMkKw3xfpm4No?p=preview

    0 讨论(0)
提交回复
热议问题