0
How to create a dynamic form at the angular, this form is composed of categories and types. It was supposed to create a tab
with the various categories and within each category show the types.
Below follows the example of the code.
<div class="row">
<div class="col-xs-12">
<div class="box box-primary">
<div class="box-body" id="teste" ng-app="app" ng-init="chargeData()" ng-controller="FormCtrl">
<ul class="nav nav-tabs" role="tablist">
<li ng-repeat="category in categories"><a href="#{{category.ClinicalExamCategoryId}}" data-toggle="tab">{{category.clinicalExamCategoryName}}</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" ng-repeat="category2 in categories2" id="{{category2.ClinicalExamCategoryId}}">
<br>
<div id="{{category2.ClinicalExamCategoryId}}" class="row" ng-init="chargeType(category2.ClinicalExamCategoryId);">
<div ng-repeat="type in types " id="{{category2.ClinicalExamCategoryId}}" class="col-xs-6">
<div id="{{type.ClinicalExamTypeId}}" class="box box-primary">
<div class="box-header">
<h3 class="box-title" id="{{type.clinicalExamTypeName}}">{{type.clinicalExamTypeName}}</h3>
<div class="box-body">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Controler:
$scope.chargeData = function () {
$http.get("/ClinicalExams/SelectCategory").success(function (data, status, headers, config) {
$scope.categories = data;
$scope.categories2 = data;
// chargeType(id);
}).error(function (data, status, headers, config) {
$scope.state = "ERRO DE EXECUÇÃO";
});
}
$scope.chargeType = function (id) {
$http.get("/ClinicalExams/SelectType/"+id).success(function (data, status, headers, config) {
$scope.types = data;
}).error(function (data, status, headers, config) {
$scope.state = "ERRO DE EXECUÇÃO";
});
}
All Categories
– Bruno Santos
How do these categories return? JSON? You missed explaining what’s wrong with your code, what’s the problem.
– Renan Gomes
he sends via json categories. But in each category he should make a call to fetch the types corresponding to that category
– Bruno Santos