Discussions

Ask a Question
Back to All

Dependency Injection not working properly

My understanding of the dependency injection was that it would load all of the files and AFTER all of them are loaded and executed it would process the Javascript. At the moment i have some dependency injections but the code in my .directive on the module im loading is being run ahead of time. When i try to add code about the stuff being loaded in the .directive (not the link just before the return) I sometimes get an error saying that ex: React has not been loaded or whatever other source hasn't finished executing.

angular.module('ocxGrid', [
["../directives/ocx-grid/ocx-grid.min.css?version=" + window.ocxRouterVersion,
window.ocxExternalDependenciesPath + 'jqueryUIMinimal/jquery-ui-1.10.4.custom.min.css?version=' + window.ocxRouterVersion,
window.ocxExternalDependenciesPath + 'jqueryUIMinimal/jquery-ui-1.10.4.custom.min.js?version=' + window.ocxRouterVersion
],
{
files: [
window.ocxExternalDependenciesPath + 'react/react.development.js?version=' + window.ocxRouterVersion,
//window.ocxExternalDependenciesPath + 'react/react.production.min.js?version=' + window.ocxRouterVersion,
window.ocxExternalDependenciesPath + 'react/react-dom.development.js?version=' + window.ocxRouterVersion,
//window.ocxExternalDependenciesPath + 'react/react-dom.production.min.js?version=' + window.ocxRouterVersion,
window.ocxExternalDependenciesPath + 'react-tooltip/standalone/react-tooltip.min.js?version=' + window.ocxRouterVersion
],
serie: true
}
])
.directive('ocxGrid', ['utils', '$timeout', '$parse', '$ocLazyLoad', '$q', function(utils, $timeout, $parse, $ocLazyLoad, $q){
;

//This will insert here a concatenated version of all the files in components folder
/ ocx file insert /

return {
restrict: 'E',
scope: {
gridOptions:'=oaGridOptions'
},
template: '

',
link: function(p_scope, p_element, p_attrs){
ReactDOM.render(, p_element[0]);
}
};
}]);