2013-11-11 3 views
3

AngularJS 1.2.0 только что выпустили, и есть мгновенная проблема для CounchDB и MongoDB пользователей:

При попытке получить доступ к некоторым данным JSON предшествует подчеркивание, как {{data._id}} Угловая 1.2.0 дает следующее сообщение об ошибке:

Error: [$parse:isecprv] 

Там есть обсуждение этой here on the docs.

Есть ли способ отключить эту функцию или преодолеть ее?

+0

@elclanrs Правда, хотя по крайней мере, в моем случае я использую '' ._id' поле MongoDB' в течение всего моего приложения, и это будет означать всего много возиться с полями данных. Возможно, ваш вариант может быть единственным вариантом, но я надеюсь, что есть несколько возможных способов полностью отключить эту функцию, а не изменять дизайн моей базы данных. – Jascination

+1

Это, на мой взгляд, плохой ход сторонников angular.js. Начните читать здесь обходные пути и дополнительную информацию: https://github.com/angular/angular.js/pull/4509 – TheHippo

ответ

4

Чтобы отключить эту функцию «» в 1.2.0, закомментируйте строки 9097 до 9101. Эти 5 строк отвечают за Error: [$parse:isecprv]:

if (name.charAt(0) === '_' || name.charAt(name.length-1) === '_') { 
throw $parseMinErr('isecprv', 
    'Referencing private fields in Angular expressions is disallowed! Expression: {0}', 
    fullExpression); 
} 
2

Похоже, нам придется подождать, пока 1.2.1 был выпущен.

13 ноября 2013Vojta сказал the following об этом 'особенность':

Guys, sorry for the troubles this change caused. This "feature" was mostly for people using Closure compiler and Google JS style, but I didn't realize that many people were relying on accessing _* properties in templates. For now we are reverting that change (4ab16aa).

We gonna release 1.2.1 (which will contain this "fix") within next days.

The main outcome of this issue is: we should not put any breaking changes into RC. Lesson learned.

Обновление - 15 ноября 2013:AngularJS 1.2.1 underscore-empathy reverts hiding "private" properties.

We introduced "private" properties (for properties prefaced with an underscore) in 1.2 thinking that this would be a fairly uncontroversial change. Oops! Apologies (and thank you) to the folks who filed bugs alerting us to the larger consequences in your code of making this breaking change. We've reverted this feature.

Смежные вопросы