Created
March 15, 2014 09:00
-
-
Save ArnauAregall/9563709 to your computer and use it in GitHub Desktop.
AngularJS - Minifying application module with $interpolateProvider setting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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(); | |
)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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