簡體   English   中英

ngRoute似乎不起作用。 角1.5.7

[英]ngRoute doesn't seem to work. angular 1.5.7

我知道這個主題有幾個問題,但是沒有一個主題可以幫助我解決問題。

我有:-404錯誤-browserLink:37 [Deprecation]不贊成在主線程上使用同步XMLHttpRequest,因為它對最終用戶的體驗有不利影響。 如需更多幫助,請訪問https://xhr.spec.whatwg.org/ 警告

HTML:

<script src="~/app/app.js"></script>
<script src="~/app/controller.js"></script>
<script src="~/app/parkingCtrl.js"></script>

app.js

(function (angular) {
'use strict';

angular.module("app", ["ngRoute"])

    .config(['$routeProvider', '$httpProvider', '$locationProvider', 
      function ($routeProvider, $httpProvider, $locationProvider) {

        $locationProvider.html5Mode({
            enabled: true,
            requireBase: false
        });

        $httpProvider.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";


        $routeProvider.
            when("/parking", {
                template: '/locelec/voiturelist',
                controller: "parkingCtrl",
            });

    }]) 



})(window.angular);

1檔

angular.module('app').controller('FirstController', function () { });

2檔

angular.module('app').controller('parkingCtrl', ['$rootScope', '$scope', '$routeParams', 
  function ($rootScope, $scope, $routeParams) {

}]);

花了整個周末的時間試圖弄清楚路線,開始感到絕望:)謝謝您的幫助。 最好的祝福。

提示:

<script type="text/ng-template" id="/locelec/voiturelist">
<div class="page page-dashboard ng-scope" ng-controller="parkingCtrl">

  <div class="row">
    <div class="col-md-12">
      <h1>Voitures</h1>
    </div>
  </div>
  <div class="row">
    <div class="col-md-12">
      <a class="btn btn-primary" role="button" href="#/bicycles/new">
        Ajoutez nouveau voiture
      </a>
    </div>
  </div>
  <div class="row">
    <div class="col-md-12">
      &nbsp;
    </div>
  </div>
  <div class="row">
    <div class="col-md-12">
      <table class="table table-bordered table-striped">
        <thead>
          <tr>
            <th>Id</th>
            <th>Marque</th>
            <th>Modele</th>
            <th>Carburant</th>
            <th>Numbre de Portes</th>
            <th>Transmission</th>
            <th>Consommation</th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          <tr ng-repeat="vehicule in model.listvehicules | filter: {TypeVehicule : 'voiture'}">
            <td>{{vehicule.Id}}</td>
            <td>{{vehicule.Marque}}</td>
            <td>{{vehicule.Modele}}</td>
            <td>{{vehicule.Carburant}}</td>
            <td>{{vehicule.NumPortes}}</td>
            <td>{{vehicule.Transmission}}</td>
            <td>{{vehicule.Consommation}}</td>
            <!--<td>
              <a class="btn btn-default" role="button" 
                 ng-link="['VoitureEdit', {id: vehicule.Id}]">
                Edit {{vehicule.Id}}
              </a>
            </td>-->
            <td>
              <a class="btn btn-default" role="button" ng-link="['VoitureEdit']">
                 Edit VoitureEdit
              </a>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>
</script>

關鍵問題是

<ng-view></ng-view>

失蹤。

在這個非常不錯的教程的幫助下,我意識到了這一點。 AngularJS路由配置

謝謝大家!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM