[英]Add HTML Page to div
I have angular template , which has a div. 我有角模板,其中有一个div。 I am trying to load html view ( .html ) page to the div based on a $watch. 我试图基于$ watch将html视图(.html)页面加载到div。 But, It never loads the html view to the div. 但是,它永远不会将html视图加载到div。 Here is my controller , I am only posting the part of the code that loads the html view. 这是我的控制器,我只发布了加载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);
});
});
Here is my HTML. 这是我的HTML。
<div class="locationChart_container">
<div class="locationChart_left">
</div>
<div class="locationChart_right">
</div>
Can anybody suggest me where I am doing the mistake , if possible please let me know if there is a angular way of doing this. 有人可以向我建议我在哪里做错了,如果可能的话,请告诉我是否有解决此问题的方法。
You need to add $scope.$apply() or inject $timeout and add it to the code to notify angular of your changes 您需要添加$ scope。$ apply()或注入$ timeout并将其添加到代码中以通知您的更改角度
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);
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.