V
V
Vyacheslav Popov2015-02-26 15:30:48
Angular
Vyacheslav Popov, 2015-02-26 15:30:48

How to properly set up a REST ful API?

when using html5Mode to discard the hash#, there is a problem with navigating to the address. I use a virtual server, the start page is localhost:9999 , in the config it looks like this

var portfolioApp = angular.module('portfolioApp', ['ngRoute', 'ngMaterial', 'portfolioControllers']);

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

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

    $routeProvider.
      when('/', {
        templateUrl: 'partials/home.html',
        controller: 'HomeCtrl'
      }).
      when('/service', {
        templateUrl: 'partials/service.html',
        controller: 'ServiceCtrl'
      }).
      when('/works', {
        templateUrl: 'partials/works.html',
        controller: 'WorksCtrl'
      }).
      when('/about', {
        templateUrl: 'partials/about.html',
        controller: 'AboutCtrl'
      }).
      otherwise({
        redirectTo: '/'
      });
  }
]);

at the same time, all clicks on links with the href="/service" attribute , followed by loading into ng-view service.html and, as expected, in the address bar, I see - localhost:9999/service
or a link with the href="/" attribute - with loading in ng-view home.html --- work! if I enter localhost:9999
into the address bar with handles - it also works! But, if I enter the address localhost:9999/service or localhost:9999/works into the address bar , then on the white screen I get: Cannot GET /service or Cannot GET /works , respectively

. This is the first and terrible problem. Help
The second problem - when replacing an HTML page in ng-view with another one, I go to a new page but with a lowered scroll, at the same distance as I finished viewing the previous page. Probably $location will help here , but how? Help

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question