1

phonegapと を使用して Web アプリを作成していIonicます。各 HTML ページを別のファイルに書きたいのですが、うまくいきません。APIではIonic、次の例のみを示します。

<script id="templates/home.html" type="text/ng-template">
  <ion-view view-title="Home">
    <ion-content class="padding">
      <p>
        <a class="button icon icon-right ion-chevron-right" href="#/tab/facts">Scientific Facts</a>
      </p>
    </ion-content>
  </ion-view>
</script>

<script>これは、ページ内のタグ内に記述された HTML コードですindex.html。たとえば、次の名前で別のファイルを作成しようとしたところhome.html、次のエラーが表示されました。

XMLHttpRequest はファイルをロードできません: path-to-the-file。クロス オリジン リクエストは、http、data、chrome-extension、https、chrome-extension-resource のプロトコル スキームでのみサポートされています。

jsは次のようになります。

angular.module('myApp', ['ionic'])


.config(function ($stateProvider, $urlRouterProvider) {
// Set and define states
$stateProvider
    .state('/', {
        url: '/',
        templateUrl: 'index.html'
    })
    .state('home', {
        url: '/home',
        templateUrl: 'templates/home.html'
    });

$urlRouterProvider.otherwise("/");

}))

およびhtmlページ:

<ion-view title="home">
<ion-content>
   The content of the page 
  <a href="#/home">Register</a>
</ion-content>

登録リンクのあるindex.htmlページが表示されますが、クリックしても何も実行されません。<script>タグでラップされている場合にのみ機能するようです。助言がありますか?

4

1 に答える 1