1

私はAngularが初めてです...

いくつかのルートが定義されたアプリケーションを作成しました。

app = angular.module("LgiClient", ['ngCookies', 'buildings','ngResource']).config(['$routeProvider', '$locationProvider' ,
($routeProvider, $locationProvider) ->
  #$locationProvider.hashPrefix('');
  $locationProvider.html5Mode true
  $routeProvider.when("/",
    controller: "RaffleCtrl"
    templateUrl: "<%= asset_path('raffle/index.html') %>"
  ).when("/buildings", 
    controller: BuildingsIndexCtrl
    templateUrl: '<%= asset_path("buildings/index.html") %>'
  ).when("/buildings/new",
    controller: BuildingsCreateCtrl
    templateUrl: '<%= asset_path("buildings/new.html") %>'
  ).when("/buildings/:id",
    controller: BuildingsShowCtrl
    templateUrl: '<%= asset_path("buildings/show.html") %>'
  ).when("/buildings/:id/edit",
    controller: BuildingsEditCtrl
    templateUrl: '<%= asset_path("buildings/edit.html") %>'
  ).otherwise redirectTo: "/"
])

このルート「/buildings/:id/edit」をたどると、次のテンプレートに移動します。

<form name="editBuilding">
  <fieldset>
    <legend>
      Edit Building
    </legend>
      <div ng-include src="'buildings/form.html'"></div>
    <div class="form-actions">
      <button class="btn btn-success" ng-click="save()"
        ng-disabled="isClean() || editBuilding.$invalid">
        Save
      </button>
      <button ng-click="destroy()"
              ng-show="building.id"
              class="btn btn-danger">
              <i class="icon-trash"></i>Delete
      </button>
      <a href="/buildings" class="btn">
        Back to buildings
      </a>
    </div>
  </fieldset>
</form>

ng-include ディレクティブは、同じディレクトリにある別のファイルを参照します。

ただし、このページを実行しても機能しません。ng-include は、間違ったリクエストを発行するため、インクルードを見つけられません:

http://127.0.0.1:3000/buildings/1/buildings/form.html

それ以外の

http://127.0.0.1:3000/buildings/buildings/form.html"

どうすればこれを修正できますか?

ありがとう!

4

0 に答える 0