Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ngmin

 ngmin

Short presentation for first AngularJS Vienna meet up on April 17th, 2014.

Hannes Stiebitzhofer

January 17, 2014
Tweet

More Decks by Hannes Stiebitzhofer

Other Decks in Programming

Transcript

  1. Angular does the magic via Dependency Injection var app =

    angular.module("app", []); app.service("Store", function() { this.products = { item: "apple" }; }); app.controller("AppCtrl", function ($scope, Store) { $scope.products = Store.products; });
  2. 'Annotations' for names fixes the problem var app = angular.module('app',

    []); app.service('Store', function() { this.products = { item: 'apple' }; }); app.controller('AppCtrl', [ '$scope', 'Store', function ($scope, Store) { $scope.products = Store.products; } ]);
  3. ngmin adds the annotations automatically Installation npm install -g ngmin

    Command line usage ngmin somefile.js somefile.annotate.js Install for usage in grunt npm install grunt-ngmin --save-dev
  4. Unfortunately global variables aren’t supported yet 'use strict'; var RabhApp

    = angular.module(‚RabhApp' ['ngResource', ‚ngRoute']); ! RabhApp.factory('PostModel', function($resource) { return $resource(‚/posts/:post_id' {post_id:’@id’})….
  5. ngmin for Ruby on Rails Add to Gemfile gem 'ngmin-rails'

    Integrates seamlessly into the Rails asset pipeline Illustrated by my boilerplate app found on Github https://github.com/stiebitzhofer/rails- angular-bower-heroku