gpt4 book ai didi

javascript - 观看 ng-include 事件?

转载 作者:行者123 更新时间:2023-12-04 01:35:05 32 4
gpt4 key购买 nike

谁能给我一个例子,说明如何在 ng-include 上观察发射事件?准确地说,我想在我的指令中观察 $includeContentLoaded 事件......这是我的 html:

<div class="page_container">
<div ng-include="menu" class=""></div>
<section>
<about ng-click="loadpantone()">

</about>
<div class="pantone_wrapper">
<div ng-include="template" tabindex="0" id="focus_force" ng-keydown="keypress($event.keyCode)" ng-class="PrevNext" class="pantoneani remo pantonebg blue" ></div>
</div>
</section>
<section class="right_side"><p>Build a Web doctor</p></section>
</div>

指令:

'use strict';
/*global $:false */
angular.module('bawdApp')
.directive('about', function () {
return {
templateUrl: 'views/pantone-inner.html',
restrict: 'AE',
link: function postLink($scope, element, $emit) {
function border(valueWidth){
$('.page_cont_wrap').css('border', valueWidth+'px solid #aaFFFF');
}
$(element).css({'position': 'absolute'}).delay(200).animate({
'margin-left': '-160px',
'margin-top': '-233px',
'left': '50%',
'top': '50%'
}, 200);
$scope.loadpantone = function loadpantone(){
border(0);
$scope.template = $scope.pantonesAbout[0].url;
$('.top_left_logo.white img').css('position', 'fixed');
};
$scope.$watch('$includeContentLoaded', function(){
$('').focus();
});
}
};
});

Controller :

'use strict';
angular.module('bawdApp')
.controller('AboutCtrl', function ($scope) {
$scope.pantonesAbout = [
{name:'Pantone intro', url:'views/pantone_about.html'},
{name:'Pantone one', url:'views/about_patone_one.html'},
{name:'Pantone two', url:'views/about_patone_two.html'},
{name:'Pantone three', url:'views/about_patone_three.html'},
{name:'Pantone four', url:'views/about_patone_four.html'},
{name:'Pantone five', url:'views/about_patone_five.html'},

];
$scope.pantoneconter = 0;
});

最佳答案

您要查找的事件已发出。这意味着你必须通过 $on 收听:

$scope.$on('$includeContentLoaded', function(){
console.log(arguments);
});

关于javascript - 观看 ng-include 事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21664896/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com