AppCtrl.js 940 B

1234567891011121314151617181920212223242526272829
  1. angular.module('app').controller('AppCtrl', function($scope, $ocLazyLoad) {
  2. $scope.$on('ocLazyLoad.moduleLoaded', function(e, params) {
  3. console.log('event module loaded', params);
  4. });
  5. $scope.$on('ocLazyLoad.componentLoaded', function(e, params) {
  6. console.log('event component loaded', params);
  7. });
  8. $scope.$on('ocLazyLoad.fileLoaded', function(e, file) {
  9. console.log('event file loaded', file);
  10. });
  11. $scope.loadBootstrap = function() {
  12. // use events to know when the files are loaded
  13. var unbind = $scope.$on('ocLazyLoad.fileLoaded', function(e, file) {
  14. if(file === 'bower_components/bootstrap/dist/css/bootstrap.css') {
  15. $scope.bootstrapLoaded = true;
  16. unbind();
  17. }
  18. });
  19. // we could use .then here instead of events
  20. $ocLazyLoad.load([
  21. 'bower_components/bootstrap/dist/js/bootstrap.js',
  22. 'bower_components/bootstrap/dist/css/bootstrap.css'
  23. ]);
  24. };
  25. });