marcoslin / angularAMD

Facilitate use of RequireJS in AngularJS
http://marcoslin.github.io/angularAMD
MIT License
734 stars 171 forks source link

controllerUrl doesn't execute controller #161

Open riccardoroasio opened 8 years ago

riccardoroasio commented 8 years ago

Hi,

i'm trying to load a controller in this way:

   'main.toolbar@main':
         angularAMD.route({
          templateUrl:function (){ var token=$cookies.get('token'); return '/getTemplate/'+token+'/main.toolbar'; },
          controllerUrl:'/getController/'+$cookies.get('token')+'/main.toolbar.js'
        }),

The controller code is here:

define(['app','services/JSONService.js'], function (app) {

console.log("here");
app.controller('main.toolbar', function ($scope, $rootScope,$state,$mdSidenav,$location,JSONService,$cookies) {
 console.log("main.toolbar");

 $scope.toggleSidenav = function(menuId) {
    $mdSidenav(menuId).toggle();
  };

 $scope.openLink=function(url){
  $scope.toggleSidenav('left');
  if (url.substring(0, 7) == "http://")
  {
   $window.location.href = url;
  }
  else
  {
   $location.path(url);
  }
 };

 var token=$cookies.get('token');

 console.log("get partial");
 $scope.partial_url="/getPartial/"+token+"/menu-bar";

});

});

The problem is that the js is correctly loaded but the inner console.log is never fired so i think that for some reason it doesn't execute the controller.

Am I doing something wrong?

Thanks, Riccardo