如何在angularjs中调用自定义指令模板中的指令

时间:2017-09-04 08:51:11

标签: angularjs

问题

如果我选择特定的公司名称,我需要显示公司的银行详细信息并将其附加到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);

0 个答案:

没有答案