0

I have this script in one of my controllers:

function AdIssueListCtrl($scope, $http, $rootScope, $compile) {
    $rootScope.nav = {
        adsSideNav: true
    };
    //datasource for kendoui interface
    $scope.kendo_adissues = new kendo.data.DataSource({
        pageSize: 10,
        serverPaging: true,
        serverFiltering: true,
        serverSorting: true,
        transport: {
            read: {
                url: "/ads/adissue/kendo/?template=ads/ajax/json/list_adissue_kendo.html",
                dataType: "json"
            }
        },
        schema: {
            total: "count",
            data: 'fields'
        },
        sort: {'field': 'name', dir: 'asc'}
    });
    //delete
    $scope.delete = function (id) {
        var deleteuser = confirm("Are you sure you wish to delete this issue and all it's ads?");
        if (deleteuser) {
            $http.get("/ads/adissue/delete/" + id + "/").success(function (data) {
                if (data.result == 'success') {
                    $scope.kendo_adissues.read();
                }
            });
        }
    };

    //bind data
    $scope.cdb = function (e) {
        var grid = $("#adissues_grid");
        $compile(grid.contents())($scope);
    };
}
AdIssueListCtrl.$inject = ['$scope', '$compile', '$rootScope', '$http'];

I'm using a filewatcher in jetbrains PHPStorm for closure, it basically runs the following on code change.

compiler.jar --compilation_level SIMPLE_OPTIMIZATIONS --js $FileName$

where the $FileName$ is the currently open file. For some reason I'm getting the following errors.

ERROR - Parse error. missing name after . operator
    $scope.delete = function (id) {
           ^

controllers.js:47: ERROR - Parse error. syntax error
}
^

controllers.js:48: ERROR - Parse error. syntax error
AdIssueListCtrl.$inject = ['$scope', '$compile', '$rootScope', '$http'];

The script works fine non minified, but I'm at a loss as to why it's throwing up those parser errors? Any ideas?

1 Answer 1

4

In emcascript3 (older javascript), keywords like delete cannot be used as property names unless they are quoted. Just use the compiler's --language_in option to set the language to either ECMASCRIPT5 or to ECMASCRIPT5_STRICT. The other workaround is to quote the property, but that has renaming implications.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.