未捕获错误:语法错误,无法识别的表达式:#/ Locations Jquery

时间:2016-01-10 19:46:00

标签: javascript jquery html angularjs

嗨我从jquery得到这个错误。 在索引中。我有一个href

<li><a href="/#/Locations">Locations</a></li>

在我的app.js中我有这个:

var app = angular.module('storeApp', ['ngRoute'])

app.config(['$routeProvider',function($routeProvider){
    $routeProvider
    .when('/Locations',
    {
        controller : 'LocationController',
        templateUrl : '/client/Location/Locations.html'
    })

}]);

这是堆栈:

Uncaught Error: Syntax error, unrecognized expression: #/Locations
error @ jquery.min.js:4
gt @ jquery.min.js:4
kt @ jquery.min.js:4
ot @ jquery.min.js:4
x.fn.extend.find @ jquery.min.js:5
x.fn.x.init @ jquery.min.js:4
x @ jquery.min.js:4
i.getCurrentSection @ jquery.singlePageNav.min.js:8
i.checkPosition @ jquery.singlePageNav.min.js:8
i.init @ jquery.singlePageNav.min.js:8
(anonymous function) @ jquery.singlePageNav.min.js:8
x.extend.each @ jquery.min.js:4
x.fn.x.each @ jquery.min.js:4
e.fn.singlePageNav @ jquery.singlePageNav.min.js:8
(anonymous function) @ custom.js:34
l @ jquery.min.js:4
c.fireWith @ jquery.min.js:4
x.extend.ready @ jquery.min.js:4
S @ jquery.min.js:4

我有LOCATIONS控制器的js文件可能会出错:

var groupLocationByCityFromController;

angular.module(&#39; storeApp&#39)控制器(&#39; LocationController&#39 ;,     函数($ rootScope,$范围,$ HTTP){

    //Get all locations from server
    $http({
        method: 'GET',
        url: '/LocationJSON'
    }).then(function success(res){
        $scope.locations = res.data.JSON;
    }, function err(){
        console.log("Error the the LocationJSON");
    });

    //Edit page
    $scope.getEdit = function(location){
        $rootScope.locationToEdit = location;
        if ($rootScope.locationToEdit != undefined && $rootScope.locationToEdit != null) {
         window.location.href = '/#/Locations/editLocation';
        }
        else
            console.log("Error in getEdit");
    }

    //Update after edit
    $scope.updateLocation = function(location) {
        console.log("Update:" + location);
        $http({
            method: "POST",
            url: '/location',
            data: location
        }).then (function success(res) {
            console.log("success in updating:" + location);
            window.location.href = '/#/Locations';
        }, function err(res) {
            console.log("Error in updating:" + location);
        });
    }

    //delete location by id
    $scope.deleteLocation = function(locationId){
        $http({
            method : "DELETE",
            url : '/deleteLocation' + "=" + locationId
        }).then (function success(res){
            console.log("Success in Deleting Location id: " + locationId);
            $scope.locations = res.data.JSON;
        },function err (res){
            console.log("Error in deleting location id: " + locationId);
        });
    }

    //Group by city
    $scope.groupLocationByCity = function() {
        $http({
            method : "GET",
            url: '/locationByCity'
        }).then (function success(res) {
            groupLocationByCityFromController=res.data;
            $rootScope.groupLocationByCity = res.data;
            window.location.href = '/#/Locations/GroupLocationByCity';
        }, function err(res){
            console.log("Error with location group by");
            window.location.href = '/#/Locations';
        });
    }

    //load create page
    $scope.getCreate = function () {
        window.location.href = '/#/Locations/LocationsCreate';
    }

    //create new location
    $scope.createLocation = function (newLocation) {
        $http ({
            method : "PUT",
            url : '/createNewLocation',
            data :newLocation
        }).then (function success(res) {
            console.log('create new location');
            window.locations.href = '/#/Locations';
        },function err (res){
            console.log("Error creating new Location");
        })
    }

});

我该如何解决这个错误

0 个答案:

没有答案