angularjs - ui-router states with oclazyload does not load a new module to the app -



angularjs - ui-router states with oclazyload does not load a new module to the app -

i trying load new module "testlazy" app when defining states in app.config using oclazyload , ui-router

will need require.js hooked load new module existing app? thought oclazyload reference new module added app. please right me if on wrong path

here new module placed under

/js/testlazy module.js testlazycontroller.js

i have module.js file , testlazycontroller.js.

in index.html

<head> <script type="text/javascript" src="../../dist/oclazyload.js"> </script> <script type="text/javascript" src="js/app.js"></script> </head> <body class="container"> <h1 class="page-header">$oclazyload</h1> <div ui-view="lazyloadview"></div> </body>

my app.js

var amodule = angular.module('dapp', ['ui.router','oc.lazyload']); amodule.config(['$locationprovider', '$stateprovider', '$urlrouterprovider', '$httpprovider', '$oclazyloadprovider', function ($locationprovider, $stateprovider, $urlrouterprovider, $httpprovider, $oclazyloadprovider) { $stateprovider .state('testlazyload', { parent: 'authenticated', url: '^/testlazyload', templateurl: 'html/templates/header.html', controller: "testlazycontroller", resolve: { // property in resolve should homecoming promise , executed before view loaded loadmyctrl: ['$oclazyload', function($oclazyload) { // can lazy load files existing module homecoming $oclazyload.load('js/testlazy/testlazycontroller.js'); }] } }); $urlrouterprovider.otherwise('/login'); }]);

my testlazycontroller.js

angular.module('testlazy').controller('testlazycontroller', ['$scope', '$q', 'modalservice', '$state', '$filter', '$oclazyload', function ($scope, $q, modalservice, $state, $filter, $oclazyload) { console.log("lazyloading complete"); }]);

my module.js

angular.module('testlazy', []);

i maintain getting error: $injector:nomod module unavailable error in console.

once refrence js files in index.html using script tags works no longer using teh lazy loading correct?

i not quety familiar oclazyload , not sure if help seek utilize this:

loadmyctrl: ['$oclazyload', function($oclazyload) { // can lazy load files existing module homecoming $oclazyload.load({ name:'testlazy', files: 'js/testlazy/testlazycontroller.js'}); }]

or must configure $oclazyloadprovider

$oclazyloadprovider.config({ modules: [{ name: 'testlazy', files: ['js/testlazy/testlazycontroller.js'] }]

}); after configuration should able load module this:

loadmyctrl: ['$oclazyload', function($oclazyload) { // can lazy load files existing module homecoming $oclazyload.load('testlazy'); }]

angularjs angular-ui-router angular-ui-router-extras

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -