Skip to content

Instantly share code, notes, and snippets.

@ArnauAregall
Created March 15, 2014 09:00
Show Gist options
  • Save ArnauAregall/9563709 to your computer and use it in GitHub Desktop.
Save ArnauAregall/9563709 to your computer and use it in GitHub Desktop.
AngularJS - Minifying application module with $interpolateProvider setting.
(function(){}(
/*
* Define an application module which needs external directives (someDirectives.js).
* The application should set the $interpolateProvider start and end syntax, like : #{foo.bar}
* It will need to be minified later.
*/
var app = angular.module('myApp', ['someDirectives'],
['$interpolateProvider', function($interpolateProvider) {
$interpolateProvider.startSymbol('#{');
$interpolateProvider.startSymbol('}');
}]
);
// other app code, you could safely apply app.config here
app.run();
));
/*
* Define a simple controller for 'myApp' which needs to make a POST request when the $scope function 'submit' is called.
* It will need to have $scope and $http dependencies injected.
* It will need to be minified later.
*/
function SomeController($scope, $http) {
$scope.submit = function() {
$http.post('/foo', $scope.model).success(ok).error(fail);
};
function ok(data) {
console.log('Yay! : ' + data)
}
function fail(err) {
console.error('Ouch! : ' + error);
};
}
SomeController.$inject = ['$scope', '$http'];
angular.module('myApp', []).controller('SomeController', SomeController);
/*
* Define a non application dependant module of directives, which will need to be minified later.
*/
var someDirectives = angular.module('someDirectives', []);
someDirectives.directive('directiveOne', ['$http', function($http) {
return {
// TODO build some directive which uses $http service
}
}]);
someDirectives.directive('directiveTwo', ['$q', function($q) {
return {
// TODO build some directive which uses $q promises
}
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment