Skip to content

bem-contrib/enb-ng-techs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

cd4c7bc · Jul 13, 2015

History

12 Commits
Jun 5, 2015
Jun 22, 2015
Jun 5, 2015
May 26, 2015
Jun 5, 2015
Jun 5, 2015
Jun 5, 2015
Jun 22, 2015
May 26, 2015
Jul 13, 2015
Jun 22, 2015
Jul 11, 2015

Repository files navigation

enb-ng-techs

NPM version Travis AppVeyor

Useful ENB technologies to build angular projects.

Installation:

$ npm install --save-dev enb-ng-techs

Techs

  • ng-annotate - adds AngularJS dependency injection annotations using ng-annotate
  • ng-templates - combines *.tmpl.html files in single partial which can be loaded and compiled by Angular in runtime

ng-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

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 <script type="text/ng-template"> 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

nodeConfig.addTech(require('enb-ng-techs/techs/ng-templates'));

Use this snippet in project based on ui-router to fetch and compile templates.

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();
            });
    });

About

Useful enb technologies to build angular projects

Resources

License

Stars

Watchers

Forks

Packages

No packages published