$parse:AngularJS中的语法错误

$parse:AngularJS中的语法错误,angularjs,Angularjs,我有一个程序,根据作者对单词进行排序,这是一个数组。我在控制台中收到$parse:syntax错误;但是,程序正在执行并返回正确的结果。我不确定是什么导致了这个问题。我使用标签和书籍等其他属性对单词进行排序;但是,此控制台错误仅由这些阵列中的某些实例显示 这就是它的样子: 错误如下: angular.js:13236 Error: [$parse:syntax] Syntax Error: Token 'Baggins' is an unexpected token at column 7 o

我有一个程序,根据作者对单词进行排序,这是一个数组。我在控制台中收到$parse:syntax错误;但是,程序正在执行并返回正确的结果。我不确定是什么导致了这个问题。我使用标签和书籍等其他属性对单词进行排序;但是,此控制台错误仅由这些阵列中的某些实例显示

这就是它的样子:

错误如下:

angular.js:13236 Error: [$parse:syntax] Syntax Error: Token 'Baggins' is an unexpected token at column 7 of the expression [Frodo Baggins] starting at [Baggins].
http://errors.angularjs.org/1.5.0/$parse/syntax?p0=Baggins&p1=is%20an%20unexpected%20token&p2=7&p3=Frodo%20Baggins&p4=Baggins
    at http://localhost:8080/node_modules/angular/angular.js:68:12
    at Object.AST.throwError (http://localhost:8080/node_modules/angular/angular.js:13816:11)
    at Object.AST.ast (http://localhost:8080/node_modules/angular/angular.js:13586:12)
    at Object.ASTCompiler.compile (http://localhost:8080/node_modules/angular/angular.js:14040:31)
    at Parser.parse (http://localhost:8080/node_modules/angular/angular.js:14927:29)
    at $parse (http://localhost:8080/node_modules/angular/angular.js:15035:39)
    at http://localhost:8080/node_modules/angular/angular.js:20463:17
    at Array.map (native)
    at processPredicates (http://localhost:8080/node_modules/angular/angular.js:20452:26)
    at http://localhost:8080/node_modules/angular/angular.js:20416:22(anonymous function) @ angular.js:13236(anonymous function) @ angular.js:9965Scope.$digest @ angular.js:16682Scope.$apply @ angular.js:16928clickListener @ angular-material.js:14066defaultHandlerWrapper @ angular.js:3398eventHandler @ angular.js:3386
angular.js:13236 Error: [$parse:syntax] Syntax Error: Token 'Baggins' is an unexpected token at column 7 of the expression [Frodo Baggins] starting at [Baggins].
http://errors.angularjs.org/1.5.0/$parse/syntax?p0=Baggins&p1=is%20an%20unexpected%20token&p2=7&p3=Frodo%20Baggins&p4=Baggins
    at http://localhost:8080/node_modules/angular/angular.js:68:12
    at Object.AST.throwError (http://localhost:8080/node_modules/angular/angular.js:13816:11)
    at Object.AST.ast (http://localhost:8080/node_modules/angular/angular.js:13586:12)
    at Object.ASTCompiler.compile (http://localhost:8080/node_modules/angular/angular.js:14040:31)
    at Parser.parse (http://localhost:8080/node_modules/angular/angular.js:14927:29)
    at $parse (http://localhost:8080/node_modules/angular/angular.js:15035:39)
    at http://localhost:8080/node_modules/angular/angular.js:20463:17
    at Array.map (native)
    at processPredicates (http://localhost:8080/node_modules/angular/angular.js:20452:26)
    at http://localhost:8080/node_modules/angular/angular.js:20416:22(anonymous function) @ angular.js:13236(anonymous function) @ angular.js:9965Scope.$digest @ angular.js:16682processQueue @ angular-material.js:1316(anonymous function) @ angular.js:18744completeOutstandingRequest @ angular.js:5804(anonymous function) @ angular.js:6081
<md-input-container>
        <label>Books</label>
        <md-select ng-model="book">
            <md-option ng-repeat="book in books | orderBy: book" value="{{ book }}"> <!-- books here refers to a newly defined array that stores only one instance of all the books against the 'book' property on each object/word -->
                {{ book }} 
            </md-option>
        </md-select>
    </md-input-container>
function getBooks(classifieds) {

        var books = [];
        angular.forEach(classifieds, function(item) {
            if (item.meta) {    
                angular.forEach(item.meta.book, function(b) {

                    books.push(b);
                });
            }

        });

        return _.uniq(books);

    }
JSON如下所示

{
"expression": "to the day",
"meaning": "",
"example": "it's been four years to the day.",
"pronunciation": "",
"notes": "",
"meta": {
"book": ["There and back again"],
"author": ["Frodo Baggins"],
"tags": ["middle earth"]}
},
视图中的代码如下所示:

angular.js:13236 Error: [$parse:syntax] Syntax Error: Token 'Baggins' is an unexpected token at column 7 of the expression [Frodo Baggins] starting at [Baggins].
http://errors.angularjs.org/1.5.0/$parse/syntax?p0=Baggins&p1=is%20an%20unexpected%20token&p2=7&p3=Frodo%20Baggins&p4=Baggins
    at http://localhost:8080/node_modules/angular/angular.js:68:12
    at Object.AST.throwError (http://localhost:8080/node_modules/angular/angular.js:13816:11)
    at Object.AST.ast (http://localhost:8080/node_modules/angular/angular.js:13586:12)
    at Object.ASTCompiler.compile (http://localhost:8080/node_modules/angular/angular.js:14040:31)
    at Parser.parse (http://localhost:8080/node_modules/angular/angular.js:14927:29)
    at $parse (http://localhost:8080/node_modules/angular/angular.js:15035:39)
    at http://localhost:8080/node_modules/angular/angular.js:20463:17
    at Array.map (native)
    at processPredicates (http://localhost:8080/node_modules/angular/angular.js:20452:26)
    at http://localhost:8080/node_modules/angular/angular.js:20416:22(anonymous function) @ angular.js:13236(anonymous function) @ angular.js:9965Scope.$digest @ angular.js:16682Scope.$apply @ angular.js:16928clickListener @ angular-material.js:14066defaultHandlerWrapper @ angular.js:3398eventHandler @ angular.js:3386
angular.js:13236 Error: [$parse:syntax] Syntax Error: Token 'Baggins' is an unexpected token at column 7 of the expression [Frodo Baggins] starting at [Baggins].
http://errors.angularjs.org/1.5.0/$parse/syntax?p0=Baggins&p1=is%20an%20unexpected%20token&p2=7&p3=Frodo%20Baggins&p4=Baggins
    at http://localhost:8080/node_modules/angular/angular.js:68:12
    at Object.AST.throwError (http://localhost:8080/node_modules/angular/angular.js:13816:11)
    at Object.AST.ast (http://localhost:8080/node_modules/angular/angular.js:13586:12)
    at Object.ASTCompiler.compile (http://localhost:8080/node_modules/angular/angular.js:14040:31)
    at Parser.parse (http://localhost:8080/node_modules/angular/angular.js:14927:29)
    at $parse (http://localhost:8080/node_modules/angular/angular.js:15035:39)
    at http://localhost:8080/node_modules/angular/angular.js:20463:17
    at Array.map (native)
    at processPredicates (http://localhost:8080/node_modules/angular/angular.js:20452:26)
    at http://localhost:8080/node_modules/angular/angular.js:20416:22(anonymous function) @ angular.js:13236(anonymous function) @ angular.js:9965Scope.$digest @ angular.js:16682processQueue @ angular-material.js:1316(anonymous function) @ angular.js:18744completeOutstandingRequest @ angular.js:5804(anonymous function) @ angular.js:6081
<md-input-container>
        <label>Books</label>
        <md-select ng-model="book">
            <md-option ng-repeat="book in books | orderBy: book" value="{{ book }}"> <!-- books here refers to a newly defined array that stores only one instance of all the books against the 'book' property on each object/word -->
                {{ book }} 
            </md-option>
        </md-select>
    </md-input-container>
function getBooks(classifieds) {

        var books = [];
        angular.forEach(classifieds, function(item) {
            if (item.meta) {    
                angular.forEach(item.meta.book, function(b) {

                    books.push(b);
                });
            }

        });

        return _.uniq(books);

    }

我认为答案很简单——订购人应该是:
|订购人:'book'

安装chrome并尝试使用它翻页。在调试中,您可以单击error,它将在angular网站上打开一个页面。本页将解释一点错误,请编写完整的JS代码$scope.books=getBooks(分类广告)这将调用上面显示的getBooks函数哦,是的。。我在引号里加了它<代码>无运行时错误。但是,标记数组中的值现在没有按字母顺序排序。奇怪的是,它们是在我将它添加到引号中之前出现的;但是,这些值是按书籍列表中的字母顺序排序的,书籍包含在引号中——我没有得到前面提到的运行时错误;但是,现在的值不是按字母顺序排列的。在我对您的回答的第一个评论中,我的意思是——但是,BOOK数组(不是Tag)中的值现在不是按字母顺序排列的。奇怪的是,在我把它添加到引号中之前,它们就已经存在了。现在可以用了。我认为原语在默认情况下不会排序,但可以传入函数。将orderBy更改为orderBy:“toString()”。