|
1524 | 1524 |
|
1525 | 1525 | **[Back to top](#table-of-contents)**
|
1526 | 1526 |
|
1527 |
| -## Minification and Annotation |
| 1527 | +## Минификация и аннотация |
1528 | 1528 |
|
1529 | 1529 | ### ng-annotate
|
1530 | 1530 | ###### [Style [Y100](#style-y100)]
|
1531 | 1531 |
|
1532 |
| - - Use [ng-annotate](//github.com/olov/ng-annotate) for [Gulp](http://gulpjs.com) or [Grunt](http://gruntjs.com) and comment functions that need automated dependency injection using `/** @ngInject */` |
| 1532 | + - Используйте [ng-annotate](//github.com/olov/ng-annotate) для [Gulp](http://gulpjs.com) или [Grunt](http://gruntjs.com) и комментируйте функции, которые нуждаются в автоматической вставке зависимостей, используйте `/** @ngInject */`. |
1533 | 1533 |
|
1534 |
| - *Why?*: This safeguards your code from any dependencies that may not be using minification-safe practices. |
| 1534 | + *Why?*: Это гарантирует, что в вашем коде нет зависимостей, которые не используют защиту для повреждений от минификации. |
1535 | 1535 |
|
1536 |
| - *Why?*: [`ng-min`](https://github.com/btford/ngmin) is deprecated |
| 1536 | + *Why?*: [`ng-min`](https://github.com/btford/ngmin) не рекомендуется для применения, выводится из употребления |
1537 | 1537 |
|
1538 |
| - >I prefer Gulp as I feel it is easier to write, to read, and to debug. |
1539 |
| - |
1540 |
| - The following code is not using minification safe dependencies. |
| 1538 | + >Я предпочитаю Gulp, так как для меня он проще для чтения, написания кода и отладки. |
1541 | 1539 |
|
| 1540 | + Следующий код не использует защиту зависимостей от минификации. |
| 1541 | + |
1542 | 1542 | ```javascript
|
1543 | 1543 | angular
|
1544 | 1544 | .module('app')
|
|
1557 | 1557 | }
|
1558 | 1558 | ```
|
1559 | 1559 |
|
1560 |
| - When the above code is run through ng-annotate it will produce the following output with the `$inject` annotation and become minification-safe. |
| 1560 | + Если код выше запустить через ng-annotate, то будет произведен код с аннотацией `$inject`, и код станет устойчив к минификации. |
1561 | 1561 |
|
1562 | 1562 | ```javascript
|
1563 | 1563 | angular
|
|
1579 | 1579 | Avengers.$inject = ['storageService', 'avengerService'];
|
1580 | 1580 | ```
|
1581 | 1581 |
|
1582 |
| - Note: If `ng-annotate` detects injection has already been made (e.g. `@ngInject` was detected), it will not duplicate the `$inject` code. |
| 1582 | + Замечание: Если `ng-annotate` обнаруживает вставки которые уже сделаны (например `@ngInject` был обнаружен), он не будет дублирован в коде `$inject`. |
1583 | 1583 |
|
1584 |
| - Note: When using a route resolver you can prefix the resolver's function with `/* @ngInject */` and it will produce properly annotated code, keeping any injected dependencies minification safe. |
| 1584 | + Замечание: Если используется маршрутный обработчик, то вы можете перед встраиваемой функцией подставить `/* @ngInject */` и это будет производить корректный аннотационный код, делающий каждую вставленную зависимость безопасной для минификации. |
1585 | 1585 |
|
1586 | 1586 | ```javascript
|
1587 |
| - // Using @ngInject annotations |
| 1587 | + // Используем @ngInject аннотацию |
1588 | 1588 | function config($routeProvider) {
|
1589 | 1589 | $routeProvider
|
1590 | 1590 | .when('/avengers', {
|
|
1600 | 1600 | }
|
1601 | 1601 | ```
|
1602 | 1602 |
|
1603 |
| - > Note: Starting from AngularJS 1.3 use the [`ngApp`](https://docs.angularjs.org/api/ng/directive/ngApp) directive's `ngStrictDi` parameter. When present the injector will be created in "strict-di" mode causing the application to fail to invoke functions which do not use explicit function annotation (these may not be minification safe). Debugging info will be logged to the console to help track down the offending code. |
| 1603 | + > Замечание: Начиная с AngularJS 1.3 используйте [`ngApp`](https://docs.angularjs.org/api/ng/directive/ngApp) директивный параметр `ngStrictDi`. При наличии инжектора будет создан режим "strict-di", который не даст приложению работать, если обнаружит функции, которые не используют явные аннотации (например, для защиты от минификации). Отладочная информация будет отображаться в консоли, чтобы помочь разработчику выявить код, ломающий приложение. |
1604 | 1604 | `<body ng-app="APP" ng-strict-di>`
|
1605 | 1605 |
|
1606 | 1606 | ### Use Gulp or Grunt for ng-annotate
|
|
0 commit comments