角JS - 错误:$解析:lexerr词法错误 [英] Angular js - Error: $parse:lexerr Lexer Error

查看:362
本文介绍了角JS - 错误:$解析:lexerr词法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发展在1.2角的一个项目,我有UTF-8编码和角装订有问题,像N一些字符抛出一个错误:

I'm developing a project in angular 1.2, I have a problem with utf-8 encoding and the angular binding, some chars like "ñ" throw an error:

// HTML

//html

角度误差
词法分析器错误:意外下一个字符

Angular error Lexer Error: Unexpected next character

我有一个plunker演示

I've a plunker demo

http://plnkr.co/edit/4wlkPEKHS7TWE83ygXYL?p=$p$ PVIEW

你有任何想法是怎么回事?

Do you have any idea what's going on?

角度误差DOC是:

http://docs.angularjs.org/error/$parse/lexerr?p0=Unexpected%20next%20character%20&p1=s%200-0%20%5B%C3%B1%5D&p2=%C3%B1

http://docs.angularjs.org/error/$parse/lexerr?p0=Unexpected%20next%20character%20&p1=s%200-0%20%5B%C3%B1%5D&p2=%C3%B1

推荐答案

您可以更广泛地允许Angu​​larJs识别的字符范围以符合您的要求。这是由 angular.js 文件修改 isIdent 函数来完成,各地线9730.我这样做是为了让法国特殊字符和多一些。

You could wider the range of characters allowed in AngularJs identifiers to match your requirements. This is done by modifying the isIdent function in angular.js file, around line 9730. I did this to allow French special characters and some more.

isIdent: function(ch) {
    return ('a' <= ch && ch <= 'z' ||
            'A' <= ch && ch <= 'Z' ||
            '_' === ch || ch === '$') || 
            129 <= ch.charCodeAt(0) && ch.charCodeAt(0) <= 496; // added this line

有是在Github上这个( https://github.com老拉的请求/angular/angular.js/pull/4747 )。

There is an old pull request on Github for this (https://github.com/angular/angular.js/pull/4747).

这篇关于角JS - 错误:$解析:lexerr词法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆