How to handle the routes of my app with Express

1

Guys, I'm using a framework for the front of my app. He stays listening and whenever he clicks on a link he returns the page via Ajax request.

Note: I'm using AngularJS. With Angular I can handle routes, but it requests the file and injects the view (correct me if I said bullshit) and that is not my goal.

Css framework link: link

My problem is: I need when the user accesses routes like /user/:id I can treat this route and serve the page user.html and also can access the id and mount the page on the front retrieving the user data via id . But I can not figure out how to use Express for this.

    
asked by anonymous 23.07.2016 / 15:10

1 answer

0

Inside your route configuration file and in your controler search for $stateParams.chatId with this you get the parameter coming from the url

$stateProvider.state('tab.chat-detail', {
      url: '/chats/:chatId',
      views: {
        'tab-chats': {
          templateUrl: 'templates/chat-detail.html',
          controller: 'ChatDetailCtrl'
        }
      }
    })



 angular.module('starter.controllers', []).controller('ChatDetailCtrl', function($scope, $stateParams, Chats) {
      $scope.chat = Chats.get($stateParams.chatId);
    })
    
23.07.2016 / 16:00