Trying to implement lazy load using requirejs. Everything is fine when I am not using charts. But when I want to use charts(angular charts), not going to sucseed! Using chart.js with angular-chart.
Here is main.js:
require.config({
baseUrl: "http://localhost/ums/angular/js",
paths: {
'angular': 'lib/angular.min',
'ngRoute': 'lib/angular-route.min',
'flash': 'lib/angular-flash',
'angular-loading-bar': 'lib/loading-bar.min',
'ngAnimate': 'lib/angular-animate.min',
'ui.bootstrap': 'lib/ui-bootstrap-tpls-0.12.0',
'uniqueField': 'admin/directives/angular-unique',
'input_match': 'admin/directives/angular-input-match',
'uniqueEdit': 'admin/directives/angular-unique-edit',
'angularAMD': 'lib/angularAMD.min',
'chart.js': 'lib/Chart.min',
'angular-chart':'lib/angular-chart.min',
'app': 'admin/app',
},
waitSeconds: 0,
shim: {
'angular': { exports: 'angular'},
'angularAMD': { deps: ['angular']},
'angular-chart': { deps: ['angular','chart.js']},
'ngRoute':{ deps: ['angular']},
'angular-loading-bar':{ deps:['angular'] },
'ngAnimate': { deps:['angular'] } ,
'ui.bootstrap': {deps: ['angular'] },
'uniqueField': {deps: ['angular'] },
'input_match': {deps: ['angular'] },
'uniqueEdit': {deps: ['angular'] },
'flash': {deps: ['angular'] },
},
deps: ['app']
});
Here is app.js:
var base_url="http://localhost/ums/";
define(['angularAMD', 'ngRoute','flash','angular-loading-bar','ngAnimate','uniqueField','input_match','angular-chart'], function (angularAMD) {
var app = angular.module('angularapp', ['ngRoute','flash','angular-loading-bar','ngAnimate','uniqueField','input_match','angular-chart']);
app.config(['$routeProvider', function($routeProvider){
$routeProvider
.when('/dashboard', angularAMD.route({
title : 'Dashboard',
controller : 'dashboardCtrl',
templateUrl : base_url+'angular/partials/admin/dashboard.php',
controllerUrl: base_url+'angular/js/admin/controllers/dashboardCtrl.js'
}))
//.......................all routing ............//
.otherwise({
redirectTo : '/dashboard'
});
}]);
app.run(['$rootScope', '$route', function($rootScope, $route) {
$rootScope.$on('$routeChangeSuccess', function() {
document.title = $route.current.title;
});
}]);
// Bootstrap Angular when DOM is ready
return angularAMD.bootstrap(app);
});
How to implement dependancy between them? Any suggestions? any examples?