I am trying to work on angular.js, ui-router and require.js and feel pretty confused. I tried to follow this tutorial http://ify.io/lazy-loading-in-angularjs/ . First, let me show you my code:
app.js =>
var app = angular.module('myApp', []);
app.config(function ($stateProvider, $controllerProvider, $compileProvider, $filterProvider, $provide) {
$stateProvider.state('home',
{
templateUrl: 'tmpl/home-template.html',
url: '/',
controller: 'registration'
resolve: {
deps: function ($q, $rootScope) {
var deferred = $q.defer(),
dependencies = ["registration"];
require(dependencies, function () {
$rootScope.$apply(function () {
deferred.resolve();
});
})
return deferred.$promise;
}
}
}
);
app.lazy = {
controller: $controllerProvider.register,
directive: $compileProvider.directive,
filter: $filterProvider.register,
factory: $provide.factory,
service: $provide.service
};
});
Now in my registration.js I have the following code:
define(["app"], function (app) {
app.lazy.controller("registration" , ["$scope", function ($scope) {
$scope.message = "hello world!";
}]);
});
everything works well, even the code in registration.js is running. but the problem is that the code inside the controller function never runs, and I get the error Error: [ng: areq] http://errors.angularjs.org/1.2.23/ng/areq?p0=registration&p1=not function received undefined
It seems that my code is not registering the function of the controller. Any ideas?
P.s. ui-router : " - promises, $routeChangeSuccess." . (); timeOut , , 5 , Strange.