[英]ngRoute doesn't seem to work. angular 1.5.7
I know there is a few questions on this topic, but none of theme helped me resolved my problem. 我知道这个主题有几个问题,但是没有一个主题可以帮助我解决问题。
I have : - 404 error - browserLink:37 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. 我有:-404错误-browserLink:37 [Deprecation]不赞成在主线程上使用同步XMLHttpRequest,因为它对最终用户的体验有不利影响。 For more help, check https://xhr.spec.whatwg.org/ . 如需更多帮助,请访问https://xhr.spec.whatwg.org/ 。 warning 警告
html: HTML:
<script src="~/app/app.js"></script>
<script src="~/app/controller.js"></script>
<script src="~/app/parkingCtrl.js"></script>
app.js 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 file 1档
angular.module('app').controller('FirstController', function () { });
2 file 2档
angular.module('app').controller('parkingCtrl', ['$rootScope', '$scope', '$routeParams',
function ($rootScope, $scope, $routeParams) {
}]);
have spend all weekend trying to figure out the routing, start to desperate :) Thank you for your help. 花了整个周末的时间试图弄清楚路线,开始感到绝望:)谢谢您的帮助。 best regards. 最好的祝福。
vue : 提示:
<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">
</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>
The key problem was 关键问题是
<ng-view></ng-view>
missing. 失踪。
I realise it with help of this really nice tutorial. 在这个非常不错的教程的帮助下,我意识到了这一点。 Angularjs route configuration AngularJS路由配置
Thank you all guys ! 谢谢大家!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.