打开ngDialog,单击角度js中打开的ngDialog内的链接

时间:2015-04-09 06:09:28

标签: javascript jquery angularjs

我正在打开一个ngDialog。在这个对话框中,我有一个链接也将在相同的ngDialog中打开,刷新内容或通过关闭第一个打开另一个ngDialog。

我的代码如下:

app.controller('Main', ['$scope','$http','$location','ngDialog','$rootScope','$route','applicazioneFactory', function($scope, $http,$location, ngDialog,$rootScope,$route,applicazioneFactory) {

$scope.runjs = function(e,pd) {

         e.preventDefault();
         tp =  (-1)* jQuery(window).scrollTop(); 
        tp1 =  jQuery(window).scrollTop(); //jQuery(e.target).offset().top+300      
         jQuery('.minDiv').css({position:'fixed',top:tp})        

         $last = $location.url();
        $location.path(pd.slug,false);      
        $scope.slug = pd.slug ;
        $scope.id = pd.ID ;
        //ngDialog.closeAll();
        $scope.catId = pd.terms.category[0].ID ;
         var modalInstance = ngDialog.open({
          templateUrl: myLocalized.partials + 'content.html',
          controller: 'Content',
          scope:$scope,  
          size:'lg'
        });         

        $rootScope.$on('ngDialog.closed', function (e, $modalInstance) {
            if($location.url() != $last)
               $last = $location.url();

              $location.path($last,false);          
                 $scope.$apply();            

        });


      return false;
    }

}])

app.controller('Content', ['$scope', '$routeParams', '$http','$sce','$location','ngDialog','$rootScope', function($scope, $routeParams, $http,$sce,$location,ngDialog,$rootScope) {

$http.get(theme_url+'show-social-count.php?slug_url='+ url+$scope.slug).success(function(res){
        $scope.facebook = res.facebook;
        $scope.twitter = res.twitter;
    })

$scope.runjs = function(e,pd) {
         e.preventDefault();


        tp =  (-1)* jQuery(window).scrollTop(); 
        tp1 =  jQuery(window).scrollTop(); //jQuery(e.target).offset().top      
         jQuery('.minDiv').css({position:'fixed',top:tp})        

         $last = $location.url();
        $location.path(pd.slug,false);  

        $scope.slug = pd.slug ;
        $scope.id = pd.ID ;
        //ngDialog.closeAll();
        $scope.catId = pd.terms.category[0].ID ;

        ngDialog.close('ngdialog1');
         var modalInstance = ngDialog.open({
          templateUrl: myLocalized.partials + 'content.html',
          controller: 'Content',          
          scope:$scope,  
          size:'lg'
        });     
        $rootScope.$on('ngDialog.closed', function (e, $modalInstance) {
                    if($location.url() != $last)
                       $last = $location.url();

                      $location.path($last,false);          
                         $scope.$apply();

                });     

      return false;
    }
}]);

模板和控制器在这两种情况下是相同的,并且ngDialog框打开但数据不与模板绑定。我们如何解决这个问题?

0 个答案:

没有答案