How to handle my app routes with Express

Asked

Viewed 138 times

1

Guys, I’m using a framework for the front of my app. He keeps listening and whenever you click on a link he returns the page via Ajax request.

Note: I am using Angularjs. With Angular I can treat routes, but it requests the file and injects in the view (correct me if I said nonsense) and this is not my goal.

Link to the css framework: http://goratchet.com/

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

1 answer

0

Within your route configuration file and in your search controller $stateParams.chatIdwith this you take the parameter 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);
    })

Browser other questions tagged

You are not signed in. Login or sign up in order to post.