我看不到最快的双向绑定的加载标签。
我有一个显示和隐藏加载标签的标志。但我看不到装载标签。因为角度渲染(绑定)速度非常快。
期望1:-
所以我想
isloading
在渲染回调开始和结束时显示和隐藏标志。我希望这是我解决方案的正确方法。是否可以?
期望2:-
我检查了堆栈溢出,然后建议使用
$timeout
. 但我认为这不是一个好的解决方案。但如果我们不能实现我的第一个期望,那么我可以顺其自然$timeout
。但是这里我没有为 $timeout 函数设置大概的时间,我会在 $timeout 函数上设置准确的 DOM 渲染时间。
我为该问题制作了以下片段,您可以轻松地做出片段答案。
angular.module("app",[]).controller("controllerApp", function($scope)
{
$scope.IsLoading=true;
// now the data binding and rendering is starting
$scope.data = [
{
"FieldGroupName": "General Information",
"cocVersionDataFieldCollection": [
{
"DocumentVersionFieldId": 1,
"FieldGroupName": "General Information",
"FieldPrefix": "0.1",
"FieldName": "Make",
"DisplayOrder": 1,
"IsMultiElement": false,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": false,
"FieldValueCobmination": "11",
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": false,
"varaintData": {
"VersionId": "number;",
"DocumentVersionFieldId": "number",
"VariantId": "number",
"ElementId": "number",
"ElementVariantId": "number",
"VariantValue": "string",
"IsRecordVisible": "boolean",
"cocElementLanguageDataCollection":[],
"hasValidationError": "boolean"
}
},
{
"DocumentVersionFieldId": 2,
"FieldGroupName": "General Information",
"FieldPrefix": "0.2",
"FieldName": "Type",
"DisplayOrder": 2,
"IsMultiElement": false,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": false,
"FieldValueCobmination": "K",
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": false,
"varaintData": null
},
{
"DocumentVersionFieldId": 1001,
"FieldGroupName": "General Information",
"FieldPrefix": "0.2",
"FieldName": "Variant",
"DisplayOrder": 3,
"IsMultiElement": false,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": false,
"FieldValueCobmination": "1",
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
},
{
"DocumentVersionFieldId": 1003,
"FieldGroupName": "General Information",
"FieldPrefix": "0.2.1",
"FieldName": "Commercial Name(s)",
"DisplayOrder": 5,
"IsMultiElement": false,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": false,
"FieldValueCobmination": "1",
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
},
{
"DocumentVersionFieldId": 3,
"FieldGroupName": "General Information",
"FieldPrefix": "0.4",
"FieldName": "Vehicle Category",
"DisplayOrder": 6,
"IsMultiElement": false,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": false,
"FieldValueCobmination": "11",
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
},
{
"DocumentVersionFieldId": 4,
"FieldGroupName": "General Information",
"FieldPrefix": "0.5",
"FieldName": "Company Name and Address of the manufacturer",
"DisplayOrder": 7,
"IsMultiElement": true,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": true,
"FieldValueCobmination": "<b>Address Line 2</b>: err; <b>Address line 3</b>: 12; ",
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
},
{
"DocumentVersionFieldId": 5,
"FieldGroupName": "General Information",
"FieldPrefix": "0.6",
"FieldName": "Location and method of attachent of satutory plates",
"DisplayOrder": 8,
"IsMultiElement": true,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": true,
"FieldValueCobmination": null,
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
},
{
"DocumentVersionFieldId": 1004,
"FieldGroupName": "General Information",
"FieldPrefix": "0.6",
"FieldName": "Location of the vechicle identification number",
"DisplayOrder": 9,
"IsMultiElement": true,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": true,
"FieldValueCobmination": null,
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
}
]
},
{
"FieldGroupName": "General Construction Characteristics",
"cocVersionDataFieldCollection": [
{
"DocumentVersionFieldId": 7,
"FieldGroupName": "General Construction Characteristics",
"FieldPrefix": "1",
"FieldName": "Number of Axles",
"DisplayOrder": 10,
"IsMultiElement": false,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": false,
"FieldValueCobmination": null,
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
},
{
"DocumentVersionFieldId": 1023,
"FieldGroupName": "General Construction Characteristics",
"FieldPrefix": "1",
"FieldName": "Number of Wheels",
"DisplayOrder": 11,
"IsMultiElement": false,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": false,
"FieldValueCobmination": null,
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
},
{
"DocumentVersionFieldId": 8,
"FieldGroupName": "General Construction Characteristics",
"FieldPrefix": "3",
"FieldName": "Powered Axles",
"DisplayOrder": 12,
"IsMultiElement": false,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": false,
"FieldValueCobmination": null,
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
},
{
"DocumentVersionFieldId": 1033,
"FieldGroupName": "General Construction Characteristics",
"FieldPrefix": "3",
"FieldName": "Powered Axles Position",
"DisplayOrder": 13,
"IsMultiElement": false,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": true,
"FieldValueCobmination": null,
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
}
]
},
{
"FieldGroupName": "Main Dimensions",
"cocVersionDataFieldCollection": [
{
"DocumentVersionFieldId": 9,
"FieldGroupName": "Main Dimensions",
"FieldPrefix": "4",
"FieldName": "Wheel Base",
"DisplayOrder": 13,
"IsMultiElement": false,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": false,
"FieldValueCobmination": "454",
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
},
{
"DocumentVersionFieldId": 1007,
"FieldGroupName": "Main Dimensions",
"FieldPrefix": "4.1",
"FieldName": "Axle spacing",
"DisplayOrder": 14,
"IsMultiElement": true,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": false,
"FieldValueCobmination": null,
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
},
{
"DocumentVersionFieldId": 10,
"FieldGroupName": "Main Dimensions",
"FieldPrefix": "5",
"FieldName": "Length",
"DisplayOrder": 15,
"IsMultiElement": false,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": false,
"FieldValueCobmination": null,
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
},
{
"DocumentVersionFieldId": 11,
"FieldGroupName": "Main Dimensions",
"FieldPrefix": "6",
"FieldName": "Width",
"DisplayOrder": 16,
"IsMultiElement": false,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": false,
"FieldValueCobmination": null,
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
},
{
"DocumentVersionFieldId": 12,
"FieldGroupName": "Main Dimensions",
"FieldPrefix": "7",
"FieldName": "Height",
"DisplayOrder": 20,
"IsMultiElement": false,
"FieldGroupID": 0,
"IsMultiRowExist": false,
"IsMultiLanguage": false,
"FieldValueCobmination": "15634",
"IsOptionExists": false,
"IsSalesVersionExists": false,
"IsMarketingcodeExists": false,
"IsMandatoryElementDataMissing": false,
"IsOverridable": true,
"varaintData": null
}
]
}
];
// now the data binding and rendering is ending
$scope.IsLoading=false;
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="controllerApp">
<span ng-show="IsLoading">loading...</span>
<table ng-repeat="obj in data">
<tr >
<td>
<b> {{obj.FieldGroupName}}</b>
<table style="border:solid 1px dashed; border-color:black">
<tr ng-repeat="objChild in obj.cocVersionDataFieldCollection">
<td>{{objChild.FieldName}}</td>
<td>{{objChild.FieldName}}</td>
<td>{{objChild.FieldName}}</td>
<td>{{objChild.FieldName}}</td>
<td>{{objChild.FieldName}}</td>
</tr>
</table>
</td>
</tr>
</table>
</div>