2015-01-15 8 views
0

저는 div가있는 각 템플리트가 있습니다. $ 시계를 기반으로 HTML보기 (.html) 페이지를 div에로드하려고합니다. 하지만, HTML 뷰를 div에로드하지 않습니다. 여기 내 컨트롤러입니다, 나는 단지 HTML보기를로드하는 코드 부분을 게시하고 있습니다.div에 HTML 페이지 추가

var filtertemplate = "#locationChart_right"; 
$scope.templateUrl = '/_layouts/AngularControls/MyController/Views/MyChart.html'; 
$scope.$watch("currentItem", function() { 

     $scope.currentConfig = $rootScope.currentItem; 
     LocDetailsChartService.getUserPrefs() 
     .then(function (response) { 
      var data = response.data.ChartsUserPrefs; 
      $scope.MeritType = data.MeritType; 
      if ($scope.MeritType !== undefined) { 
       if ($scope.MeritType == "Score") { 
        $(filtertemplate).load("/_layouts/AngularControls/MyController/Views/MyScoreChart.html"); 
       } 
       if ($scope.MeritType == "Potential") { 
        $(filtertemplate).load("/_layouts/AngularControls/MyController/Views/MyPercentChart.html"); 
       } 
      } 
      // $scope.radioButtonHandler($scope.MeritType); 
     }); 
}); 

여기 내 HTML입니다.

<div class="locationChart_container"> 
<div class="locationChart_left"> 
</div> 
<div class="locationChart_right"> 
</div> 

아무도 내가 실수를하고있는 곳을 제안 할 수 있습니다. 가능하다면이 일을하는 각도의 방법이 있다면 알려 주시기 바랍니다.

+1

https://docs.angularjs.org/api/ng 변경의 각도 통지 코드에 추가/directive/ngInclude – XGreen

답변

1

당신은 $ 범위를 추가해야합니다. $ (적용) 또는 $ 타임 아웃을 주입하고

var filtertemplate = "#locationChart_right"; 
    $scope.templateUrl = '/_layouts/AngularControls/MyController/Views/MyChart.html'; 
    $scope.$watch("currentItem", function() { 

    $scope.currentConfig = $rootScope.currentItem; 
    LocDetailsChartService.getUserPrefs() 
    .then(function (response) { 
     var data = response.data.ChartsUserPrefs; 
     $scope.MeritType = data.MeritType; 
     if ($scope.MeritType !== undefined) { 
      if ($scope.MeritType == "Score") { 
       $(filtertemplate).load("/_layouts/AngularControls/MyController/Views/MyScoreChart.html"); 
       $scope.$apply() 
      } 
      if ($scope.MeritType == "Potential") { 
       $(filtertemplate).load("/_layouts/AngularControls/MyController/Views/MyPercentChart.html"); 
       $scope.$apply() 
      } 
     } 
     // $scope.radioButtonHandler($scope.MeritType); 
    }); 
}); 
+0

감사합니다. @ generalgmt – Aj1

+0

나의 기쁨 @ Aj1. –