-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: content inside the oc-lazy-load directive is now compiled on load
Fixes #80
- Loading branch information
Showing
12 changed files
with
202 additions
and
346 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,35 @@ | ||
angular.module('app').controller('AppCtrl', ['$scope', '$ocLazyLoad', '$timeout', function($scope, $ocLazyLoad, $timeout) { | ||
$scope.$on('ocLazyLoad.moduleLoaded', function(e, params) { | ||
console.log('event module loaded', params); | ||
}); | ||
$scope.$on('ocLazyLoad.componentLoaded', function(e, params) { | ||
console.log('event component loaded', params); | ||
}); | ||
$scope.$on('ocLazyLoad.fileLoaded', function(e, file) { | ||
console.log('event file loaded', file); | ||
}); | ||
$scope.loadBootstrap = function() { | ||
var unbind = $scope.$on('ocLazyLoad.fileLoaded', function(e, file) { | ||
if(file === 'bower_components/bootstrap/dist/css/bootstrap.css') { | ||
$scope.bootstrapLoaded = true; | ||
unbind(); | ||
} | ||
}); | ||
$scope.bootstrapModule = [ | ||
'bower_components/bootstrap/dist/js/bootstrap.js', | ||
'bower_components/bootstrap/dist/css/bootstrap.css' | ||
]; | ||
} | ||
angular.module('app').controller('AppCtrl', function($scope, $ocLazyLoad) { | ||
$scope.$on('ocLazyLoad.moduleLoaded', function(e, params) { | ||
console.log('event module loaded', params); | ||
}); | ||
$scope.$on('ocLazyLoad.componentLoaded', function(e, params) { | ||
console.log('event component loaded', params); | ||
}); | ||
$scope.$on('ocLazyLoad.fileLoaded', function(e, file) { | ||
console.log('event file loaded', file); | ||
}); | ||
$scope.loadBootstrap = function() { | ||
// use events to know when the files are loaded | ||
var unbind = $scope.$on('ocLazyLoad.fileLoaded', function(e, file) { | ||
if(file === 'bower_components/bootstrap/dist/css/bootstrap.css') { | ||
$scope.bootstrapLoaded = true; | ||
unbind(); | ||
} | ||
}); | ||
// we could use .then here instead of events | ||
$ocLazyLoad.load([ | ||
'bower_components/bootstrap/dist/js/bootstrap.js', | ||
'bower_components/bootstrap/dist/css/bootstrap.css' | ||
]); | ||
} | ||
|
||
$scope.loadGridModule = function() { | ||
$ocLazyLoad.load({ | ||
name: 'gridModule', | ||
files: [ | ||
'js/gridModule.js', | ||
'partials/grid.html' | ||
] | ||
}).then(function success(data) { | ||
console.log('loaded', data); | ||
$scope.gridInclude = 'gridTemplate'; | ||
$scope.gridLoaded = true; | ||
}, function error(err) { | ||
console.log(err); | ||
}); | ||
} | ||
}]) | ||
$scope.loadGridModule = function() { | ||
$ocLazyLoad.load().then(function success(data) { | ||
console.log('loaded', data); | ||
$scope.gridInclude = 'gridTemplate'; | ||
$scope.gridLoaded = true; | ||
}, function error(err) { | ||
console.log(err); | ||
}); | ||
} | ||
}) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
// ngGrid is also lazy loaded by $ocLazyLoad thanks to the module dependency injection ! | ||
angular.module('gridModule', [{name: 'ui.grid.rowEdit', files: [ | ||
'bower_components/angular-ui-grid/ui-grid.js', | ||
'bower_components/angular-ui-grid/ui-grid.css' | ||
]}]).controller('GridModuleCtrl', ['$scope', function($scope){ | ||
$scope.myData = [{name: "Moroni", age: 50}, | ||
{name: "Teancum", age: 43}, | ||
{name: "Jacob", age: 27}, | ||
{name: "Nephi", age: 29}, | ||
{name: "Enos", age: 34}]; | ||
$scope.gridOptions = { data: 'myData' }; | ||
}]).config(function() { | ||
console.warn('config gridModule'); | ||
angular.module('gridModule', [{ | ||
name: 'ui.grid.rowEdit', files: [ | ||
'bower_components/angular-ui-grid/ui-grid.js', | ||
'bower_components/angular-ui-grid/ui-grid.css' | ||
] | ||
}]).controller('GridModuleCtrl', function($scope) { | ||
console.log('------- grid module ctrl'); | ||
$scope.myData = [{name: "Moroni", age: 50}, | ||
{name: "Teancum", age: 43}, | ||
{name: "Jacob", age: 27}, | ||
{name: "Nephi", age: 29}, | ||
{name: "Enos", age: 34}]; | ||
$scope.gridOptions = {data: 'myData'}; | ||
}).config(function() { | ||
console.warn('config gridModule'); | ||
}).config(['$ocLazyLoadProvider', function($ocLazyLoadProvider) { | ||
console.warn('config 2 gridModule'); | ||
console.warn('config 2 gridModule'); | ||
}]).run(function() { | ||
console.warn('run gridModule'); | ||
}); | ||
console.warn('run gridModule'); | ||
}); |
Oops, something went wrong.