Angularjs 如何查看所有ng init内容?
我正在为每个对象设备制作进度条 以下是我的AngularJS代码:Angularjs 如何查看所有ng init内容?,angularjs,html,Angularjs,Html,我正在为每个对象设备制作进度条 以下是我的AngularJS代码: $scope.progressBarEquipements=function(idEquipement) { $http.get(url+"/RestResponseCheckLists?idEq="+idEquipement) .success(function(data) { $scope.Pourcentage = data; }).error(function(
$scope.progressBarEquipements=function(idEquipement) {
$http.get(url+"/RestResponseCheckLists?idEq="+idEquipement)
.success(function(data) {
$scope.Pourcentage = data;
}).error(function(err, data) {
console.log("error : " +data);
});
};
此函数返回$scope.progressBarEquipements=function(idEquipement)
:
以下是我的HTML代码:
<div class="col-md-4" ng-repeat="eq in Checksf" ng-init="progressBarEquipements(eq.idEquipements)">
<h4 class="list-group-item-heading" >{{eq.nomEq}} </h4>
<div class="progress progress-lg m-b-5" >
<div class="progress-bar progress-bar-purple" role="progressbar" ng-repeat="p in Pourcentage" ng-style="{width:{{((p.NB_Resp/p.NB_checks) * 100)}} + '%'}">
{{((p.NB_Resp/p.NB_checks) * 100) | number:0}}%
</div>
</div>
</div>
{{eq.nomEq}}
{((p.NB_Resp/p.NB_检查)*100){数字:0}}
所以我有四项设备显示在html页面中
$scope.Percentage
显示了计算
只有第一个对象
如何在进度栏中显示每个对象的计算结果
提前感谢您尽管我不喜欢您使用ng init的方式,但以下几点应该可以:
$scope.progressBarEquipements=function(eq) {
$http.get(url+"/RestResponseCheckLists?idEq="+ eq.idEquipement)
.success(function(data) {
eq.Pourcentage = data;
}).error(function(err, data) {
console.log("error : " +data);
});
};
<div class="col-md-4" ng-repeat="eq in Checksf" ng-init="progressBarEquipements(eq)">
<h4 class="list-group-item-heading" >{{eq.nomEq}} </h4>
<div class="progress progress-lg m-b-5" >
<div class="progress-bar progress-bar-purple" role="progressbar" ng-repeat="p in eq.Pourcentage" ng-style="{width:{{((p.NB_Resp/p.NB_checks) * 100)}} + '%'}">
{{((p.NB_Resp/p.NB_checks) * 100) | number:0}}%
</div>
</div>
</div>
$scope.progressBarEquipements=函数(等式){
$http.get(url+”/responseechecklists?idEq=“+eq.idEquipement)
.成功(功能(数据){
等式Pourcentage=数据;
}).错误(函数(错误、数据){
console.log(“错误:+数据”);
});
};
{{eq.nomEq}}
{((p.NB_Resp/p.NB_检查)*100){数字:0}}
其想法是将您的函数“progressBarEquipements”发送给完整的设备对象。这样,您就可以在服务器响应时更新它
我不喜欢使用nginit的方法,因为
-视图的行为隐藏在控制器和模板之间。
-如果我必须这样做,我的API将提供包含我需要显示的所有信息的viewmodel。尽管我不喜欢您使用ng init的方式,但以下应该可以工作:
$scope.progressBarEquipements=function(eq) {
$http.get(url+"/RestResponseCheckLists?idEq="+ eq.idEquipement)
.success(function(data) {
eq.Pourcentage = data;
}).error(function(err, data) {
console.log("error : " +data);
});
};
<div class="col-md-4" ng-repeat="eq in Checksf" ng-init="progressBarEquipements(eq)">
<h4 class="list-group-item-heading" >{{eq.nomEq}} </h4>
<div class="progress progress-lg m-b-5" >
<div class="progress-bar progress-bar-purple" role="progressbar" ng-repeat="p in eq.Pourcentage" ng-style="{width:{{((p.NB_Resp/p.NB_checks) * 100)}} + '%'}">
{{((p.NB_Resp/p.NB_checks) * 100) | number:0}}%
</div>
</div>
</div>
$scope.progressBarEquipements=函数(等式){
$http.get(url+”/responseechecklists?idEq=“+eq.idEquipement)
.成功(功能(数据){
等式Pourcentage=数据;
}).错误(函数(错误、数据){
console.log(“错误:+数据”);
});
};
{{eq.nomEq}}
{((p.NB_Resp/p.NB_检查)*100){数字:0}}
其想法是将您的函数“progressBarEquipements”发送给完整的设备对象。这样,您就可以在服务器响应时更新它
我不喜欢使用nginit的方法,因为
-视图的行为隐藏在控制器和模板之间。
-如果我必须这样做,我的API将提供包含我需要显示的所有信息的viewmodel。根据上次修改,它与我一起工作,谢谢您,先生,我看到了您的编辑,好的,我在您的对象中缺少了“百分比”,但我认为不应该有ng重复,因为每次只有一个项目。
eq.Pourcentage
返回两个对象。如何浏览。因此,添加“ng repeat”。我测试了这个案例,它与我一起工作根据上次的修改,它与我一起工作,谢谢你,先生,我看到了你的编辑,好的,我在你的对象中丢失了“百分比”,但我认为不应该有ng重复,因为每次只有一个项目。eq.Pourcentage
返回两个对象。如何浏览。因此,添加“ng repeat”。我测试了这个案例,它对我有效