Open marcoslin opened 9 years ago
Hi marcoslin, do you have news for this issue? It's possibile to have a function for controllerUrl? The code bleow doesn't work if the controller isn't pre-loaded
.when("/:template/:id/:content_title",
angularAMD.route({
controllerUrl: function($routeParams) {
if($routeParams.template.indexOf("-") < 0){
return $routeParams.template;
}
else{
var template = $routeParams.template;
template = template.substr(0,template.indexOf("-"));
console.log(template);
return template;
}
},
template: function ($routeParams) {
return '<dn-' + $routeParams.template + '></dn-' + $routeParams.template + '>';
},
})
)
To bypass the problem at the moment I do
.when("/:template/:id/:content_title",
angularAMD.route({
resolve: {
load: ['$q', '$rootScope', '$location', '$routeParams', function ($q, $rootScope, $location, $routeParams) {
var path = $location.path();
var parsePath = path.split("/");
var template = parsePath[1];
var id = parsePath[2];
var title = parsePath[3];
if(template.indexOf("-") > 0)
template = template.substr(0,template.indexOf("-"));
var loadController = template;
var deferred = $q.defer();
require([loadController], function () {
$rootScope.$apply(function () {
deferred.resolve();
});
});
return deferred.promise;
}]
},
controllerUrl: function($routeParams) {
if($routeParams.template.indexOf("-") < 0){
return $routeParams.template;
}
else{
var template = $routeParams.template;
template = template.substr(0,template.indexOf("-"));
console.log(template);
return template;
}
},
template: function ($routeParams) {
return '<dn-' + $routeParams.template + '></dn-' + $routeParams.template + '>';
},
})
)
Thanks for help! and congrats for the angularAMD, it's fantastic
As per #117 and #121