简体   繁体   English

ng-app中的三元运算符?

[英]ternary operator in ng-app?

Iam working on a component in AEM. Iam在AEM中处理组件。 I have components with independent ng-app for each component since Iam having multiple websites in each package and using the same components across various websites. 我的每个组件都有独立的ng-app组件,因为Iam在每个程序包中都有多个网站,并且在各个网站中使用相同的组件。

Now when I drag and drop a component multiple times in a same page. 现在,当我在同一页面中多次拖放组件时。 Only one component is working. 只有一个组件在工作。 I sense it is coz of having same ng-app name. 我感觉这是因为具有相同的ng-app名称。 May I know how can I overcome it. 我可以知道如何克服它。 Coz., even though the component is same., based on requirement., we had to make differnt API call and get data respect to that section in view. 即使是相同的组件,根据要求,我们也必须进行不同的API调用,并获取有关该部分的数据。

Iam having an idea of using ternary operator inside ng-app like this 我有一个在ng-app中使用ternary operator的想法

 ng-app="{{ apiType ? type1 : type2 }}"

But not sure ternary operator fires before ng-app declaration. 但不确定ng-app声明之前会触发ternary operator

Any Ideas 有任何想法吗

Here is the sample plnkr based on inputs I received. 这是基于我收到的输入的样本plnkr。

plnkr code here 这里的plnkr代码

I got the issue resolved by adding loop to calculate the number of componets being dragged and appending unique ID (ng-app value) using for loop. 通过添加循环以计算要拖动的组件数并使用for循环附加唯一ID(ng-app值),我解决了问题。

[code here][1]

code here 这里的代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM