AngularJS маршрутизация не работает, так как при попытке просмотреть сайт загружаются индексные файлы, но не просмотр внутри ng-view - PullRequest
0 голосов
/ 25 апреля 2020

Я использовал AngularJS маршрутизацию на своем сайте, но когда я перехожу к другому представлению на сайте, URL не загружает представление и ничего не происходит. Вот мой скрипт

var app = angular.module('myApp', ['ngRoute']);
app.config(function ($routeProvider, $locationProvider) {
$routeProvider
.when('/home', {templateUrl: 'templates/home.html'})
.when('/about', {templateUrl: 'templates/about.html'})
.when('/contact', {templateUrl: 'templates/contact.html'})
.when('/disclosure', {templateUrl: 'templates/disclosure.html'})
.when('/privacy', {templateUrl: 'templates/privacy.html'})
.when('/What-is-Meetvio', {templateUrl: 'templates/What-is-Meetvio.html'})
.when('/WP-Affiliate-Suite-Review', {templateUrl: 'templates/WP-Affiliate-Suite-Review.html'})
.when('/Their-Benefits-For-Marketers', {templateUrl: 'templates/Their-Benefits-For-Marketers.html'})
.when('/this-is-the-name-of-the-title', {templateUrl: 'templates/this-is-the-name-of-the-title.html'})
.when('/Product Reviews', {templateUrl: 'templates/Product Reviews.html'})
.when('/Website Marketng', {templateUrl: 'templates/Website Marketng.html'})
.when('/Courses and Trainings', {templateUrl: 'templates/Courses and Trainings.html'})
.when('/Tips and Stratagies', {templateUrl: 'templates/Tips and Stratagies.html'})
.when('/terms', {templateUrl: 'templates/terms.html'});
$locationProvider.html5Mode(true);
});

Мой файл htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
# Redirection of requests to index.html
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) Index.html [NC,L]
</IfModule>```

Я также использовал базовый тег в Index. html как <base href="/"> Навигация в моем Index. html файл имеет вид <a class='nav-link' href='about'>About</a> <a class='nav-link' href='contact'>Contact</a>

Когда я перехожу на http://localhost/NewOne/ сайт загружается, но домашний вид не загружается внутри ng-вида, а также нет другого вида, когда нажмите как о или свяжитесь

...