我正面临一个令人讨厌的问题,我无法解决,这段代码在浏览器中完美运行,但在android / ios设备上却没有:
<ion-view style="" title="Dettaglio">
<ion-content class="has-header" padding="true">
<div style="" class="list card">
<div class="item item-divider" ng-show="conditions">{{conditions.nome}} {{conditions.cognome}}</div>
<div class="item item-divider" ng-hide="conditions">Errore!!</div>
<div class="item item-body">
<div style="" ng-show="conditions">
<p>
Residuo: {{conditions.residuo}}
</p>
</div>
<div style="" ng-hide="conditions">
<p>
Utente non registrato o codice fiscale errato
</p>
</div>
</div>
</div>
<div style="display: inline-block; width: 300px; height: 17px;" class="spacer"></div>
<div style="" class="list card" ng-show="conditions">
<div class="item item-divider">Note</div>
<div class="item item-body">
<div style="">
<p>
{{conditions.note}}
</p>
</div>
</div>
</div>
</ion-content>
在Windows浏览器中测试应用程序时,ng-hide / ng-show按预期隐藏或显示div,但是一旦我在android / ios设备上获得应用程序,无论如何都会显示每个div。 我对角度/离子有点新意,但我无法理解为什么ng-show指令在浏览器中工作但在设备上没有。
提前致谢
答案 0 :(得分:1)
我在浏览器和Android手机中都遇到了这个问题。这是由于最近Cordova的安全性升级以及需要更好的“内容安全政策”。
我通过在index.html中添加到这一行来修复它:
<meta http-equiv="Content-Security-Policy" content="default-src...
我补充说:
'unsafe-inline' 'unsafe-eval'
答案 1 :(得分:0)
I had a similar problem.
I fixed my case by inspecting the computed styles of the [ng-hide=""] element in Safari DevTools (running against the iOS simulator) to find that the Wearable.NodeApi.getConnectedNodes
rule was not being created.
My workaround has been to add that rule to my own stylesheet.