https://github.com/bem-contrib/enb-ng-techs
Useful enb technologies to build angular projects
https://github.com/bem-contrib/enb-ng-techs
Last synced: 2 months ago
JSON representation
Useful enb technologies to build angular projects
- Host: GitHub
- URL: https://github.com/bem-contrib/enb-ng-techs
- Owner: bem-contrib
- License: mit
- Created: 2015-05-26T11:54:39.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-03T19:18:04.000Z (over 9 years ago)
- Last Synced: 2025-02-20T05:47:14.812Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 208 KB
- Stars: 0
- Watchers: 12
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
enb-ng-techs
==============[](https://www.npmjs.org/package/enb-ng-techs)
[](https://travis-ci.org/bem-incubator/enb-ng-techs)
[](https://ci.appveyor.com/project/Guria/enb-ng-techs)Useful ENB technologies to build angular projects.
Installation:
----------```sh
$ npm install --save-dev enb-ng-techs
```Techs
----------* `ng-annotate` - adds AngularJS dependency injection annotations using [`ng-annotate`](https://github.com/olov/ng-annotate)
* `ng-templates` - combines `*.tmpl.html` files in single partial which can be loaded and compiled by Angular in runtimeng-annotate
==========Takes js file provided by `source` option and writes annotated result to file provided by `target` option.
**Options**
* *String* **source** — file-target to annotate.
* *String* **target** — file-target to write annotated output.**Example**
```javascript
nodeConfig.addTech(require('enb-ng-techs/techs/ng-annotate'), {
source : '?.pre.js',
target : '?.annotated.js'
});
```ng-templates
==========Combines `*.tmpl.html` files wrapping them out with `` tag and filename as `id`.
You should fetch this file and compile it in your app using $compile service before any call to templates occurred.**Опции**
* *String* **target** — Output target. Default — `?.tmpl.html`.
**Example**
```javascript
nodeConfig.addTech(require('enb-ng-techs/techs/ng-templates'));
```Use this snippet in project based on `ui-router` to fetch and compile templates.
```javascript
angular.module('ngApp')
.run(function($http, $compile, $urlRouter, $rootScope){
// make a chance to load templates before state change
var un = $rootScope.$on('$stateChangeStart', function (event) {
event.preventDefault();
});// get and compile templates
$http.get('ngapp.tmpl.html')
.then(function(response){
response.data.length &&
$compile(response.data);
// now we can safely set an state
un();
$urlRouter.sync();
});
});
```