I am using angular-ui/ui-routing. The problem lies with either my angular routing, or my server routing, I don't know which. My express routing is this:
var compositions = require('../controllers/comptroller');
module.exports = function(Compositions, app, auth) {
app.route('/critique')
.post(auth.requiresLogin, compositions.createCritique);
app.route('/users')
.get(compositions.showProfile);
app.route('/compositions/:compositionId')
.get(compositions.show)
.post(auth.requiresLogin, compositions.createCritique);
app.route('/compositions')
// .get(compositions.profile)
.get(compositions.all)
.post(auth.requiresLogin, compositions.fileUpload);
and my angular routing is this:
$stateProvider
.state('all compositions', {
url: '/compositions/recent',
templateUrl: 'compositions/views/list.html'
}).
state('create comp', {
url: '/compositions/create',
templateUrl: 'compositions/views/create.html',
resolve: {
loggedin: checkLoggedin
}
}).
state('myuser', {
url: '/users',
templateUrl: 'compositions/views/profile.html',
resolve: {
loggedin: checkLoggedin
}
}).
I am using a state machine to handle routing. When I navigate to localhost:3000/#!/users I receive my profile.html template, which is what I want. However, the GET request on my express route never gets called. I am trying to get the function 'showProfile' but it never hits the function. UNLESS, I navgiate to localhost:3000/users, then the function, showProfile gets called, but the template, profile.html does not. Could someone tell me what I am doing wrong? I need to get to the showProfile function in order to query my mongo database. Any advice or help is appreciated, thank you.
EDIT: Interesting to note, if I were to put compositions.showProfile in another app.route, I hit the backend function, and load the template. It's for this route, /users, it does not seem to work.