我试图在我的指令中使用Isolate范围设置一些默认值.基本上,我需要在绑定指令时使用scope对象进行一些DOM操作.以下是我的代码:
控制器:
angular.module('ctrl').controller('TempCtrl', function($scope, $location, $window, $timeout, RestService, CommonSerivce) {
$scope.showAppEditWindow = function() {
//Binding the directive isolate scope objects with parent scope objects
$scope.asAppObj = $scope.appObj;
$scope.asAppSubs = $scope.appSubscriptions;
//Making Initial Settings
CommonSerivce.broadcastFunction('doDirectiveBroadcast', "");
};
Run Code Online (Sandbox Code Playgroud)
服务:
angular.module('Services').factory('CommonSerivce', function ($rootScope) {
return {
broadcastFunction: function(listener, args) {
$rootScope.$broadcast(listener, args);
}
};
Run Code Online (Sandbox Code Playgroud)
指示:
angular.module('directives').directive('tempDirective', function() {
return {
restrict : 'E',
scope:{
appObj:'=asAppObj',
appSubs: '=asAppSubs'
},
link : function(scope, element, attrs) {},
controller : function ($scope,Services,CommonSerivce) {
//Broadcast Listener
$scope.$on('doDirectiveBroadcast', function …Run Code Online (Sandbox Code Playgroud) angularjs angularjs-directive angularjs-service angularjs-scope
我正在使用jPlayer播放音频.我们需要不间断的比赛.为此,我们使用jQuery.load()方法加载页面内容并替换页面上的内容.
我们没有以任何方式刷新jPlayer内容.
代码在firefox中工作正常,jPlayer播放音频而不会中断.但是在chrome和safari上,jPlayer会在执行jquery load方法后停止然后重新启动.
此外,当我在本地计算机上运行代码时,它们在任何浏览器中都不会中断.只有当我在服务器上运行代码时,它们才会中断.
我们需要音乐不受干扰.
我的代码如下:
function loadContent(pagePath) {
//Method called on menu click to load content without page refresh
//Loading the said page (pagePath - relative path of page)
jQuery('#containerDiv').fadeOut(200, function() {
jQuery('#waitingDiv').show();
jQuery(this).empty();
jQuery(this).load(pagePath, function() {
jQuery(this).fadeIn(200, function() {
jQuery('#waitingDiv').hide();
});
});
});
}
//JPlayer initiation code on first page load
jQuery("#jquery_jplayer_1").jPlayer({
ready: function () {
jQuery(this).jPlayer("setMedia", {mp3: '../'+path});
},
swfPath: "../swf",
supplied: "mp3",
wmode: "window"
});
Run Code Online (Sandbox Code Playgroud)
有什么建议?
谢谢Akhilesh Aggarwal