Dynamic URL doesn't work with HTML5 angularjs

تعرفه تبلیغات در سایت
عنوان عکس عنوان عکس عنوان عکس عنوان عکس
عنوان عکس عنوان عکس عنوان عکس عنوان عکس
عنوان عکس عنوان عکس عنوان عکس عنوان عکس
عنوان عکس عنوان عکس عنوان عکس عنوان عکس
عنوان عکس عنوان عکس عنوان عکس عنوان عکس

آرشیو مطالب

جستجوگر

یافته ها در جستجو

    امکانات وب

    برچسب ها

    I'm creating an app in AngularJS and ExpressJS and when I try to use dynamic url, with the angular state, it doesn't work properly. It's working when I access directly the URL but only static URLs.

    server.js

    var express = require('express'),
    server = express(),
    path = require('path'),
    port = process.env.PORT || 8081;
    
    server.use(express.static(__dirname));
    server.all("/*", function(req, res, next) {
            res.sendFile(path.join(__dirname, 'index.html'));
        });
    server.listen(port);
    console.log('Use port ' + port + ' to connect to this server');
    
    exports = module.exports = server;
    
    

    appRoute.js

    angular
        .module('appRoutes', ["ui.router"])
        .config(['$stateProvider', '$urlRouterProvider', '$locationProvider',
        function($stateProvider, $urlRouterProvider, $locationProvider) {
    
        $stateProvider
            .state({
                name: 'home',
                url: '/home',
                templateUrl: 'public/components/auth/templates/home.html',
            })
            .state({
                name: 'set-password',
                url: '/register/:hashcode',
                templateUrl: 'public/components/register/templates/register.html',
                controller: 'RegisterController'
            });
    
        $urlRouterProvider.otherwise('/');
        $locationProvider.html5Mode(true);
    }]);
    
    

    I got a JavaScript error in the browser console, when I try to access an URL like 'http://localhost:8081/register/1234'. The error is:

    SyntaxError: expected expression, got '<' angular

    I feel that I need to change something in the server configuration but I don't know what exactly.

  • مطالب مرتبط
  • What is difference between dynamic pointer allocation for a single variable and array?
  • How to dynamically load urls (in the form if images) in collection view in swift ios?
  • ngSanitize : badparse for gives bad parse error angularjs
  • Dynamically storing array values in C
  • JSfiddle not evaluating AngularJs $scope variables
  • Android - Resize UI widget created dynamically
  • نویسنده : استخدام کار بازدید : 71 تاريخ : چهارشنبه 3 خرداد 1396 ساعت: 2:34
    برچسب‌ها :