{"action":"created","issue":{"url":"https://api.github.com/repos/ocombe/ocLazyLoad/issues/165","labels_url":"https://api.github.com/repos/ocombe/ocLazyLoad/issues/165/labels{/name}","comments_url":"https://api.github.com/repos/ocombe/ocLazyLoad/issues/165/comments","events_url":"https://api.github.com/repos/ocombe/ocLazyLoad/issues/165/events","html_url":"https://github.com/ocombe/ocLazyLoad/issues/165","id":68598178,"number":165,"title":"LazyLoad a module from javascript directly","user":{"login":"gvandyk","id":11956996,"avatar_url":"https://avatars.githubusercontent.com/u/11956996?v=3","gravatar_id":"","url":"https://api.github.com/users/gvandyk","html_url":"https://github.com/gvandyk","followers_url":"https://api.github.com/users/gvandyk/followers","following_url":"https://api.github.com/users/gvandyk/following{/other_user}","gists_url":"https://api.github.com/users/gvandyk/gists{/gist_id}","starred_url":"https://api.github.com/users/gvandyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvandyk/subscriptions","organizations_url":"https://api.github.com/users/gvandyk/orgs","repos_url":"https://api.github.com/users/gvandyk/repos","events_url":"https://api.github.com/users/gvandyk/events{/privacy}","received_events_url":"https://api.github.com/users/gvandyk/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-04-15T07:17:02Z","updated_at":"2015-04-15T09:24:08Z","closed_at":"2015-04-15T09:24:08Z","body":"I want to write a component/module that is totally self contained and I don't want to change code in other modules/controllers to load my module.\r\n\r\nCurrently I include a javascript file at the bottom of an html file that defines all the logic, controllers, components, directives etc.\r\n\r\nHow can I LazyLoad this file, without having to update another controller somewhere.\r\n\r\nfor instance: LazyLoadModule('mymodule.js'), instead of having the $ocLazyLoad service available.\r\n\r\nUsing the oc-lazy-load directive works perfectly well, if I surround all my html with a div that includes that directive. However I also need to write components with which I cannot do this.\r\n\r\nSo, in short: How can I call LazyLoad to load my module directly from within Javascript."},"comment":{"url":"https://api.github.com/repos/ocombe/ocLazyLoad/issues/comments/93280597","html_url":"https://github.com/ocombe/ocLazyLoad/issues/165#issuecomment-93280597","issue_url":"https://api.github.com/repos/ocombe/ocLazyLoad/issues/165","id":93280597,"user":{"login":"gvandyk","id":11956996,"avatar_url":"https://avatars.githubusercontent.com/u/11956996?v=3","gravatar_id":"","url":"https://api.github.com/users/gvandyk","html_url":"https://github.com/gvandyk","followers_url":"https://api.github.com/users/gvandyk/followers","following_url":"https://api.github.com/users/gvandyk/following{/other_user}","gists_url":"https://api.github.com/users/gvandyk/gists{/gist_id}","starred_url":"https://api.github.com/users/gvandyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvandyk/subscriptions","organizations_url":"https://api.github.com/users/gvandyk/orgs","repos_url":"https://api.github.com/users/gvandyk/repos","events_url":"https://api.github.com/users/gvandyk/events{/privacy}","received_events_url":"https://api.github.com/users/gvandyk/received_events","type":"User","site_admin":false},"created_at":"2015-04-15T09:24:08Z","updated_at":"2015-04-15T09:24:08Z","body":"Thanks Olivier\r\n\r\nI tried the following:\r\n\r\nmyMod.html\r\n```\r\n1: <div oc-lazy-load=\"['/static/js/nux/workflow/taskList.js']\">\r\n2: \t<div ng-controller='TaskListPageController as ctrl'>\r\n3:\t\t{% verbatim %}\r\n4:\t\t\t<span>{{ctrl.name}}</span>\r\n5:\t\t{% endverbatim %}\r\n6:\t</div>\r\n7:</div>\r\n8:\r\n9:<script>\r\n10:var injector = angular.element(document.body).injector();\t\r\n11:\r\n12:injector.invoke(function($ocLazyLoad) {\r\n13:\t$ocLazyLoad.load(['/static/js/nux/workflow/taskList.js']);\r\n14:});\t\r\n15:</script>\r\n```\r\n\r\ntaskList.js\r\n```\r\nangular.module('myApp')\r\n\t.controller('TaskListPageController',['$scope', function($scope) {\r\n\t\tthis.name = 'Testing Controller worked';\r\n\t}]);\r\n```\r\n\r\nWhen I comment out line: \r\n"}}