无法访问angularJs

时间:2016-07-28 08:35:46

标签: angularjs angularjs-ng-repeat visualforce

查看:

<div ng-controller = "ClPortalRegistrationController">

    <div ng-repeat="(key, value) in ObjectApiFieldsetMap">
        {{key}}  {{value}} //this is printing correct result
        <c:FieldSetComponent objectAPIName="'{{key}}'" fieldSet="'{{value}}'" cid="'{{key}}'" 
                             sectionTitle="Section 1" columns="2" textAlign="center"></c:FieldSetComponent>
    </div> 
</div>

控制器:

$scope.ObjectApiFieldsetMap = {
 Applications__c: "Application_FieldSet_One",
 clcommon__Collateral__c: "Collateral_FieldSet_One"
};

现在,当我尝试访问{{key}},{{value}}内的c:FieldSetComponent时,它只传递{{key}}{{value}}字符串,而不是转换后的结果。如何访问存储在组件内的键,值内的值?

1 个答案:

答案 0 :(得分:0)

发布我实施的解决方案。

事实证明,您无法访问visualforce组件内的角度合并字段值。因此,我不必在角度控制器内操纵(将输入隔离到键值对)值,而是将逻辑推送到顶点控制器。

<apex:component controller="RegistrationController" access="global">
   <apex:repeat value="{!ObjectApiFieldsetMap}" var="apiName"> 
          <c:FieldSetComponent objectAPIName="{!apiName}" fieldSet="{!ObjectApiFieldsetMap[apiName]}"  
             cid="{!apiName}{!ObjectApiFieldsetMap[apiName]}" 
              columns="1" textAlign="center">
          </c:FieldSetComponent> 

   </apex:repeat>
</apex:component>

在我的顶级控制器,即RegistrationController中,我设置了逻辑,以便从我在visualforce组件内部使用的地图输入中分离键值

global class RegistrationController {

global Map<String,String> ObjectApiFieldsetMap { 
                              get {
                                   ObjectApiFieldsetMap = arrangeApiFieldSetsByOrder();
                                   return ObjectApiFieldsetMap;
                                   } 
                                   set; 
    }

    global Map<String,String> arrangeApiFieldSetsByOrder() {

        Map<String,String> ObjectApiFieldsetMap =  new Map<String,String>();
                   /* logic for segregation */
        return ObjectApiFieldsetMap;
    }
}