离子NAV-视图>上述&lt显示HTML内容; [英] Display html content in <ion-nav-view>

查看:142
本文介绍了离子NAV-视图>上述&lt显示HTML内容;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经有过< D​​IV NG-视图>< / DIV> 之前,我使用离子。我将使用 DIV 作为包装包含任何 HTML 我想要的。

I used to have <div ng-view></div> before i use ionic. I will use that div as a wrapper to contain any html i want.

我试着做离子同样的事情。这是我的 index.html的

I tried to do the same thing with ionic. This is my index.html :

<ion-pane>
  <ion-content>
    <ion-nav-view></ion-nav-view>
  </ion-content>
</ion-pane>

这是我的离子路由器

app.config(function($stateProvider, $urlRouterProvider) {
    $stateProvider.state('main', {
        url: '/',
        templateUrl: 'views/main.html'
    })

    $urlRouterProvider.otherwise('/jobs')
})

但其不加载的意见/ main.html中

我想在我的使用文/ NG-模板的意见/ main.html中,所以它看起来像这样的:

I tried to use text/ng-template in my views/main.html, so it looks like this :

<div>
    <ion-view>
        <p></p>
    </ion-view>
</div>

但它仍然没有加载。有在控制台没有错误或警告。

But its still not loading. There is no error or warning in the console.

请好心帮助我。感谢您的帮助。

Please kindly help me. Thanks for your help.

更新

如果我用错了templateUrl HTML路径,控制台显示错误:

If i use wrong html path in templateUrl, the console shows error :

GET http://localhost:8100/views/main2.html 404 (Not Found)

然而,当我使用了正确的道路,教改(只有

)不显示。

However when i use the correct path, the cotent (only a

) is not displayed.

推荐答案

您有您的模板2的解决方案,我觉得你混合两个解决方案

You have 2 solutions for your template, and I think you mixed the two solutions


  1. 您可以把它包装&LT;脚本类型=文/ NG-模板ID =main.html中&GT;&LT; / SCRIPT&GT; 但你必须在CLUDE你的页面manualy &LT; SCRIPT SRC =&GT;&LT; / SCRIPT&GT; 。如果您使用此解决方案,您不必写路径路由 templateUrl:意见/ main.html中的id是不够 templateUrl:main.html中

  1. you can wrap it in <script type="text/ng-template" id="main.html"></script> but you will have to in clude your page manualy <script src=""></script> .If you use this solution, you don't have to write the path in routing templateUrl: 'views/main.html' the id is enough templateUrl: 'main.html'

简单地把你解开内容&LT;离子视图&gt;&LT;! - 内容 - &GT;&LT; /离子视图&gt; 在一个HTML文件,并写入templateUrl的正确路径

Simply put your unwrapped content <ion-view><!--content--></ion-view> in a html file and write the correct path in templateUrl

这篇关于离子NAV-视图&gt;上述&lt显示HTML内容;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆