我正在尝试使用 angularjs 中的路由从 Materialize 框架运行函数 .parallax() 。我已经为每个模板配置了命令 document.ready 但这不起作用。这只是第一次。使 document.ready 调用 $('.test').test(); 这样的函数的最佳方法是什么?使用路线?我将等待!谢谢!
我的路线的模板 HTML:
<!-- JS -->
<script type="text/javascript">
$(document).ready(function(){
$('.parallax').parallax(); //Run just in the first time
};
</script>
<!-- Template -->
<div class="" ng-controller="homeCtrl">
...
</div>
控制器:
app.controller('homeCtrl', ['$scope', function($scope){
//Ready
angular.element(document).ready(function() {
$('.parallax').parallax(); // Doesn't work
});
}]);
谢谢!