2013-11-24 85 views

回答

3

您可以偵聽路線改變成功事件和調用回調內部的功能:除了

$scope.$on('$routeChangeSuccess', function(next, current) { 
    // call your functions here 
}); 
+0

哪裏是你應該把它添加到您的代碼? –

0

加入以下$的scope.on你也可以當採用NG-INIT添加自定義功能控制器被調用(新視圖狀態)。

HTML:

<div class="container-fluid" ng-controller="home-services" ng-init="init()"> 
    --- Code --- 
</div> 

ANGULARJS:

angular.module('home').controller('home-services', function($scope){ 
    $scope.init = function(){ 

    ---- Your Javascript ---- 

    }; 
}); 
相關問題