I am getting details from an api which is an array of object.
(function() {
'use strict';
angular.module('myApp.components')
.directive('abc', abc);
abc.$inject = ['$http', '$timeout', 'ApiServices'];
function abc($http, $timeout, ApiServices) {
return {
restrict: 'EA',
scope: {},
link: function (scope, el, attrs) {
$('#bankMaster').on('hide.bs.modal', function() {
scope.list=[];
});
$('#bankMaster').on('shown.bs.modal', function() {
scope.list=[];
scope.getAllDetails = function() {
ApiServices.getAllDetails().then(
function (response) {
scope.list = response.data;
},
function (err) {
// Handle error here
console.log('Error' + JSON.stringify(err.data));
});
};
},
templateUrl: 'js/folder/abc.html'
};
}
})();
ich diese Daten auf Front-End zu zeigen versuchen: -Wie in AngularJS Daten auf Formular anzuzeigen
<form class="form-horizontal" name="abcForm">
<div class="form-group">
<label>User Type :</label>
<label>{{list[0].userType}}</label>
<label>User Code :</label>
<label>{{list[0].userCode}}</label>
<label>Cost Price :</label>
<label>{{list[0].costPrice}}</label>
</div>
<div class="form-group">
<label>Purchase Date :</label>
<label>{{list[0].date}}</label>
<label>Taxes :</label>
<label>{{list[0].taxes}}</label>
<label>Other : {{list[0].other}}</label>
</div>
</form>
Aber nichts bekommen displayed.My Syntax ist richtig, aber ich denke, dass ich eine anderes mache Fehler, den ich nicht verstehen kann. Kann mir jemand sagen, was in diesem Code falsch ist?
Mein Apiservices Code: -
(function() {
'use strict';
angular
.module('myApp.core')
.factory('ApiServices', ApiServices);
/* @ngInject */
function ApiServices($q, $rootScope, $http) {
return {
getAllDetails: getAllDetails
};
function getAllDetails() {
return $http({
method: 'GET',
url: '/api/abc/data/'
});
}
};
})();
können Sie einige falsche Daten von response.data –
Wo ist abc-Richtlinie auf Ihrem HTML? – Max
Bitte Code für ApiServices angeben – madhur