zoukankan      html  css  js  c++  java
  • angularjs 路由问题处理收集

    Angular 路由状态发生改变时可以通过

     $stateChangeStart 

     $stateChangeSuccess 

     $stateChangeError

    监听,通过注入$location'实现状态的管理

    function run($ionicPlatform, $location, Service, $rootScope, $stateParams) { 
      //路由监听事件 
      $rootScope.$on('$stateChangeStart', 
        function(event, toState, toParams, fromState, fromParams) { 
         console.log(event); 
         console.log(toState); 
         console.log(toParams); 
         console.log(fromState); 
         console.log(fromParams); 
         if (toState.name == "homePage") { 
          //获取参数之后可以调请求判断需要渲染什么页面,渲染不同的页面通过 $location 实现 
          if (toParams.id == 10) { 
           //$location.path();//获取路由地址 
           // $location.path('/validation').replace(); 
           // event.preventDefault()可以阻止模板解析 
          } 
         } 
        }) 
       // stateChangeSuccess 当模板解析完成后触发 
      $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) { 
      
      }) 
      
      // $stateChangeError 当模板解析过程中发生错误时触发 
      $rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) { 
      
      }) 
     }
    

    在页面渲染中 可通过$viewContentLoading 和  $viewContentLoaded监听页面渲染状态:渲染开始和渲染结束。

    scope.$watch('$viewContentLoading',function(event, viewConfig){ 
     alert('模板加载完成前'); 
    }); 
    //$viewContentLoaded- 当视图加载完成,DOM渲染完成之后触发,视图所在的$scope发出该事件。 
    $scope.$watch('$viewContentLoaded',function(event){ 
      alert('模板加载完成后'); 
    });
  • 相关阅读:
    oracle常规操作
    shell 的算数运算
    sed 命令小结
    swing
    索引失效
    poj--1258--Agri-Net(最小生成树)
    CodeForces--626C--Block Towers (二分)
    Codeforces--629A--Far Relative’s Birthday Cake(暴力模拟)
    Codeforces--629B--Far Relative’s Problem(模拟)
    hdoj--5104--Primes Problem(素数打表)
  • 原文地址:https://www.cnblogs.com/dangou/p/7504839.html
Copyright © 2011-2022 走看看