Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用angularjs在末尾加载jquery_Jquery_Angularjs_Sharepoint - Fatal编程技术网

使用angularjs在末尾加载jquery

使用angularjs在末尾加载jquery,jquery,angularjs,sharepoint,Jquery,Angularjs,Sharepoint,大家好,我是jquery和angularjs的新手(已经在.net应用程序中进行了jquery验证,但没有太多经验,所以请耐心听我说) 我希望我的jquery代码在下面的angular js是我的控制器类之后运行 我需要的是悬停时,我必须显示子菜单(这是通过jquery完成的) 我尝试了这个“viewContentLoaded”,但仍然没有成功 jquery函数在ready上被调用,但它首先在我的控制器数据之前被调用 var MenuCtrl = ['$scope', '$rootScope',

大家好,我是jquery和angularjs的新手(已经在.net应用程序中进行了jquery验证,但没有太多经验,所以请耐心听我说) 我希望我的jquery代码在下面的angular js是我的控制器类之后运行 我需要的是悬停时,我必须显示子菜单(这是通过jquery完成的) 我尝试了这个“viewContentLoaded”,但仍然没有成功 jquery函数在ready上被调用,但它首先在我的控制器数据之前被调用

var MenuCtrl = ['$scope', '$rootScope', '$filter', '$location', '$route', 'Data', function ($scope, $rootScope, $filter, $location, $route, Data) {

    $scope.menu = Data;

    $scope.selected = 0;
    $scope.setSelected = function (index) {

        $scope.selected = index;
    };

    $scope.$on('$viewContentLoaded', function () {
        alert('loaded');
    });

}];

**My HTML -Angular**
 <section ng-repeat="m in menu track by $index">
                    <section class="item">
                         <div class="item-destinations" ">
                            <a ng-href="{{m.PageURL}}">{{m.Title}}-{{$index}}</a>
                        </div>
                    </section>

**My jquery**

$('.item-destinations').hover(
        function (e) {
            e.stopPropagation();
            $('.navExpand').stop().animate({
                top: "63"
            }, 300, function () {
                destMenuOpen = true;
            });
        },
        function (e) {
            e.stopPropagation();
        }
    );
var MenuCtrl=['$scope','$rootScope','$filter','$location','$route','Data',函数($scope,$rootScope,$filter,$location,$route,Data){
$scope.menu=数据;
$scope.selected=0;
$scope.setSelected=函数(索引){
$scope.selected=索引;
};
$scope.$on(“$viewContentLoaded”,函数(){
警报(“已加载”);
});
}];
**我的HTML-Angular**

正如您所发现的,jQuery在向DOM添加元素之前附加了
hover
事件处理程序。使用
jQuery.on()
将事件处理程序进一步附加到DOM上,以通过传播侦听
上的
mouseover
mouseout
事件

$(document).on({
    mouseenter: function (e) {
        e.stopPropagation();
        $('.navExpand').stop().animate({
            top: "63"
        }, 300, function () {
            destMenuOpen = true;
        });
    },
    mouseleave: function (e) {
        e.stopPropagation();
    }
}, '.item-destinations');

也考虑把这个行为封装成一个角度指令。

嗨,安东尼,谢谢你的回答,我会把它包含在指令中。