I'm building an app using AngularJS. The environment already has several modules embedded in it, some of which I'm loading fine using require. I'm trying to add a novel one, and I can't get the steps right.
The module is color-picker.js: https://github.com/Alberplz/angular-colorpicker-directive
This is what I am trying, but not sure where to add the dependency. If I add it to the array in that first argument, I get "Reference error: angular not defined". I thought require() was supposed to resolve dependencies first before executing code.
<script>
require(['angular', './js/color-picker.js', 'components/shared/index'], function (angular) {
var app = angular.module('app', ['colorpicker']);
app.controller('AppCtrl', ['$scope', function ($scope) {
$scope.var3 = '#ff2e00';
$scope.var4 = '#e6ff00';
$scope.var5 = '#db00ff';
$scope.var6 = '#1fd27f';
$scope.var7 = '#008fff';
$scope.var8 = '#ff2e00';
$scope.var9 = '#e6ff00';
}]);
});
</script>
This next code works, but I do need to load other modules that pertain to this environment to get other components of the app working.
<link rel="stylesheet" type="text/css" href="css/color-picker.min.css" />
<script src="/scripts/lib/angular/angular.min.js"></script>
<script src="js/color-picker.min.js"></script>
<script>var app = angular.module('app', ['colorpicker']);</script>
<script>
app.controller('AppCtrl', ['$scope', function ($scope) {
$scope.var3 = '#ff2e00';
$scope.var4 = '#e6ff00';
$scope.var5 = '#db00ff';
$scope.var6 = '#1fd27f';
$scope.var7 = '#008fff';
$scope.var8 = '#ff2e00';
$scope.var9 = '#e6ff00';
}]);
</script>
I'm a require() noob and don't understand how to tell require that this new module is dependent on Angular.