javascript - angularjs infinite request loop for $resource -


for reason when hit route in angular crash browser , node server freaks out making tons of requests:

get /bower_components/bootstrap/dist/js/bootstrap.js?_=1402331354670 200 3ms - 53.96kb /js/app.js?_=1402331354671 200 1ms - 1.56kb /js/controllers/main.js?_=1402331354672 200 2ms - 140b /js/controllers/login.js?_=1402331354673 200 3ms - 735b /js/controllers/userlist.js?_=1402331354674 200 2ms - 120b /js/controllers/signup.js?_=1402331354675 200 1ms - 465b /js/controllers/profile.js?_=1402331354676 200 1ms - 665b /js/controllers/courselist.js?_=1402331354677 200 1ms - 369b /js/controllers/coursedetails.js?_=1402331354678 200 4ms - 281b /js/filters/titleize.js?_=1402331354685 200 1ms - 381b /bower_components/jquery/dist/jquery.min.js?_=1402331354686 200 2ms - 82.3kb /bower_components/angular/angular.min.js?_=1402331354687 200 1ms - 102kb /bower_components/angular-route/angular-route.min.js?_=1402331354689 200 2ms - 3.86kb ...again , again forever 

the route click:

a(ng-href='/courses/{{ course._id }}') {{ course.title }}

defined in app.js:

    $routeprovider.when('/courses/:id', {         templateurl: 'views/courses/details',         controller: 'coursedetailsctrl',     }) 

the controller:

app.controller('coursedetailsctrl', ['$scope', function($scope){     console.log('commented out. doesnt display') }]) 

the course service:

app.factory('course', ['$resource', function($resource){     var courseresource = $resource('/api/courses/:_id', {_id: '@id'}, {         update: {             method: 'put',             isarray: false         }     });      return courseresource; }]); 

on server side routes are:

app.get('/api/courses/:id', function(req, res, next){     console.log('this never logs') }) app.all('/api/*', function(req, res){     res.send(404) })  app.get('*', function(req, res){     res.render('index', {         currentuser: req.user     }) }) 

i'm confused why course partial doesn't render , browser crashes

it turns out client side route needed be

$routeprovider.when('/courses/:id', {     templateurl: '/views/courses/details',     controller: 'coursedetailsctrl', }) 

one missing / in templateurl path


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -