ocLazyLoad File not found

Posted in General by Gajendrasinh Zala Thu Apr 28 2016 06:21:10 GMT+0000 (Coordinated Universal Time)·4·Viewed 1,273 times

I have try to implement ocLazyLoad but getting error when it load Error: http://errors.angularjs.org/1.5.5/ng/areq?p0=loginController&p1=not%20a%20function%2C%20got%20undefined $stateProvider .state('Login', { url: '/', templateUrl: 'View/Login.jsp', controller : 'loginController', containerClass: 'lock-screen', pageLayout:'beforeLogin', PageTitle:'Login - FORTLABS', resolve:{ Login : function($ocLazyLoad) { return $ocLazyLoad.load( { name: "Login", files:['js/Controller/loginController.js'] } ) } } })
Apr 28, 2016

do you have the code of your controller ?

Apr 28, 2016

yes here is my controller code

xTractApp.controller('loginController', function($scope, $http, $timeout, $location, cfpLoadingBar, $state) {

// function to submit the form after all validation has occurred
$scope.user = {};

$scope.success =false;
$scope.danger =false;

$scope.submitForm = function(isValid)
{
if (isValid)
{
// cfpLoadingBar.start();
$scope.loading = true;
$timeout(function() {
$http({
method: 'POST',
url: 'AdminLogin',
headers: {'Content-Type': 'application/json'},
data: $scope.user
}).success(function (data)
{
$scope.loading = false;
// cfpLoadingBar.complete();
$scope.status=data;

                if(($scope.status=data) == "success"){
                    $state.go('Dashboard');
                    $scope.success =true;
                    $scope.message ="You Have Successfully Login !  we redirect to dashboard"; 
                }

                else{
                     $scope.loading = true;
                     $scope.danger =true;
                     $scope.message ="Something was wrong please try again";
                }

          });
       }, 1000);
   }
   else{
       $scope.loading = true;
       $scope.message ="invalid username and password";
   }

};
});

Apr 28, 2016

Just change xTractApp.controller('loginController' .... to angular.module('nameofyourmodule').controller('loginController' .... (and replace "nameofyourmodule" with the name of your module).

Apr 28, 2016

.state('Dashboard', {
url: '/Dashboard',
templateUrl: 'View/Dashboard1.jsp',
controller : 'dashboardController1',
controllerAs:'dashboardCtrl1',
containerClass: 'bg-screen',
pageLayout:'afterLogin',
PageTitle:'Dashboard - FORTLABS ',
resolve: { // Any property in resolve should return a promise and is executed before the view is loaded
loadMyCtrl: ['$ocLazyLoad', function($ocLazyLoad) {
// you can lazy load files for an existing module
return $ocLazyLoad.load([
'js/Controller/dashboardController1.js',
'js/Controller/menuController.js',
'js/Controller/notificationController.js',
'js/libs/zingchart.min.js',
'js/libs/zingchart-angularjs.js',
'js/libs/ui-bootstrap-tpls-0.14.3.js',
'js/libs/nvd3/d3.js',
'js/libs//nvd3/nv.d3.js',
'js/libs/nvd3/angularjs-nvd3-directives.js',
'js/libs/roundProgress.min.js',
'js/Directive/preloader.js'

          ]);
      }]
    }
  })

how to inject dependecy

var xTractApp = angular.module('xTractApp', [
'ui.router',
'ui.bootstrap',
'isteven-multi-select',
'ui.grid',
'ui.grid.pagination',
'ui.grid.selection',
'ui.grid.autoResize',
'ui.grid.exporter',
'nvd3ChartDirectives',
'cfp.loadingBar',
'ngBootstrap' ,
'ngResource',
'ngStorage',
'angular-svg-round-progress',
'zingchart-angularjs'
]);

  
Markdown is allowed