I am looking to create a pluginable Angular app and came across this tutorial that uses RequireJs for loading scripts in the correct order.
Now, I want to convert this project to TypeScript but I am unsure of how to incorporate RequireJs into TypeScript.
Here's an example of my App.js code:
define(['require', 'angular', 'underscore', 'src/modules/definitionsLoader.js', 'ngMaterial', 'ui.router', 'ngCookies', 'ngFileUpload' , 'src/controllers/controllers.js'],
function (require, angular, _ , definitionsLoader) {
require(definitionsLoader.scriptsToLoad, function () {
return initializeApp(angular);
});
function initializeApp(angular) {
var application = angular.module('app', definitionsLoader.modulesToLoad)
.config([
'$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.when('', '/home');
$urlRouterProvider.otherwise('/home');
$stateProvider
.state('home', {
url: '/home',
templateUrl: 'src/views/dashboard.html',
controller: function() {
},
controllerAs: 'ctrl'
});
var states = definitionsLoader.statesToConfigure;
for (var i = 0; i < states.length; i++) {
var state = states[i];
$stateProvider.state(state.stateName, { url: state.url, controllerAs:'vm' , abstract: state.abstract, templateUrl: state.templateUrl, controller: state.controller });
}
}]).run(['$rootScope', function ($rootScope) {
$rootScope.modules = definitionsLoader.modules;
}])
angular.bootstrap(document, ['app']);
};
});