私はチュートリアルに従っているときに角度ルーティングの例を見ました。私はチュートリアルとして試しましたが、うまくいきません。しかし、私はチュートリアルからコードをコピーすると完全に動作します。誰もがこれで私を助けることができます。角度ルーティングは機能しません
これが私のメインページ
<div ng-controller="routingCtrl">
<div>
<ul>
<li><a href="#home">Home</a> </li>
<li><a href="#other">Oher</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
<div>
<p>{{message}}</p>
</div>
<ng-view></ng-view>
</div>
</div>
であり、これはscript.js
var routingApp = angular.module('sampleRouting', ['ngRoute'])
.controller('routingCtrl', function ($scope) {
$scope.message = "Main Page";
})
.config(function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl: 'home.html',
controller: 'homeCtrl'
})
.when('/other', {
templateUrl: 'other.html',
controller: 'otherCtrl'
})
.when('/contact', {
templateUrl: 'contact.html',
controller: 'contactController'
})
.otherwise({ redirectTo: '/' });
})
.controller('homeCtrl', function ($scope) {
$scope.homeMessage = "Welcome to home !"
})
.controller('otherCtrl', function ($scope) {
$scope.otherMessage = "Welcome to other !"
})
.controller('contactController', function ($scope) {
$scope.contactMessage = "Welcome to Contacts !"
})
と呼ばれる私のスクリプトファイルであり、これはother.htmlある
<div>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Why do we use it?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
他の2 home.htmlとcontact.htmlも、このようなランダムなテキストが含まれています。
問題はビューはの初めにindex.htmlをにロードされたhome.htmlですが、私はその他と連絡先にコンテンツをハイパーリンクをクリックしたときにチャンスではないでしょう。 home.htmlがロードされているので、ngRouteはうまく動作すると思います。しかし、他の2つは動作しません。誰も私がこの問題を解決するのを助けることができますか?どうもありがとう。
おかげで多くを除去するため、次の試してください。これは動作します –
私のスマートなテーブルの何が間違っているか教えてもらえますか?ルーティング以外はすべて正常に動作しています [これをチェック](https://plnkr.co/edit/hb3gcgp6snBPLCA9I8qw?p=preview) –
編集:上記の問題は解決しました。ありがとう –