菜鸟教程小白 发表于 2022-12-12 09:19:04

ios - AngularJS ng-include 模板未在 Phonegap 应用程序中加载


                                            <p><p>我正在构建一个使用 AngularJS 的 iOS Phonegap 应用程序。</p>

<p>我在 <code>ng-switch</code> 中有一些 <code>ng-includes</code>,可以根据项目的类别更改某些列表项的样式。</p>

<pre><code>      &lt;div
            ng-repeat=&#34;i indata&#34;
            ng-include=&#34;src=&#39;partials/card.html&#39;&#34;&#34;
      &gt;
      &lt;/div&gt;
</code></pre>

<p>在 <em>partials/card.html</em> 文件中,是开关:</p>

<pre><code>&lt;div
ng-switch on=&#34;i.group&#34;
&gt;
&lt;div ng-switch-when=&#34;Music&#34;&gt;
    &lt;div ng-include=&#34;src=&#39;partials/card_details/&#39;+i.category+&#39;.html&#39;&#34;
    &gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div ng-switch-when=&#34;Film&#34;
    ng-include=&#34;src=&#39;partials/card_details/buy.html&#39;&#34;&gt;&lt;/div&gt;      
&lt;!-- default, load group --&gt;
&lt;div ng-switch-default ng-include=&#34;src=&#39;partials/card_details/&#39;+i.group+&#39;.html&#39;&#34;
&gt;&lt;/div&gt;
</code></pre>

<p></p>

<p>这一切都在我的桌面浏览器上的 Chrome 中完美运行,但是当我运行我的 Phonegap 应用程序时,使用与 Chrome 中运行的页面相同的符号链接(symbolic link) www 文件夹,所有内容都会加载<em>除了</em>里面的部分switch 语句。</p>

<p>我在 Xcode 控制台中没有收到任何错误,我尝试将“/”添加到 <em>src</em> 的开头,因为我在 Phonegap 中的根路径存在问题,但我不明白的是为什么 <em>partials/card.html</em> 加载而 <em>not</em> *partials/card_details*</p>

<p>有什么想法吗?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>这是不是因为下面一行中的 ng-include 末尾有双引号:</p>

<pre><code>   &lt;div
      ng-repeat=&#34;i indata&#34;
      ng-include=&#34;src=&#39;partials/card.html&#39;&#34;&#34;
    &gt;
    &lt;/div&gt;
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - AngularJS ng-include 模板未在 Phonegap 应用程序中加载,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/15168908/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/15168908/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - AngularJS ng-include 模板未在 Phonegap 应用程序中加载