问题
如果我选择特定的公司名称,我需要显示公司的银行详细信息并将其附加到HTML。
代码
(function(angular){
var app = angular.module('mypurchase',[]);
app.controller('purchasectrl',['$scope',function ($scope) {
var obj = '<%-JSON.stringify(companiesdata)%>';
var companydetails = JSON.parse(obj);
$scope.companydetails = companydetails;
$scope.getcompany = function(details){
$scope.showdiv = false;
$scope.firm_name = details.company_name;
}
}]);
app.directive('allCompanyDetails',function () {
return {
restrict: 'EA', // Element directive
template: '<div ng-repeat="details in companydetails | filter : firm_name" ng-click="getcompany(details);">{{ details.company_name }}</div><companybankdetails></companybankdetails>'
};
});
app.directive('companybankdetails',function () {
return {
restrict: 'EA', // Element directive
template: '<companybankdetails></companybankdetails>',
$scope.bankname = details.bank_name;
};
});
})(angular);