I'm trying to use angular new router in my Angular 1.5 (+ Typescript) project.
I followed the getting started manual but it forces me to have all my HTML components folder right under my root folder:
Could not instantiate controller HomeController
http://localhost:8083/components/home/home.html 404 (Not Found)
Can I change it?
My routing code is:
this.$router.config([
{ path: '/', redirectTo: '/home' },
{ path: '/home', component: 'home' }}
]);
And my component is:
namespace app.dashboard {
'use strict';
class HomeController {
}
angular.module('app.dashboard')
.component('home', {
templateUrl: 'app/dashboard/components/home.html',
controller: HomeController,
controllerAs: 'HomeController',
bindings: {}
});
}
and my nested folder is app/dashboard/components under root path
To have your html somewhere else you need to specify the templateURL like:
You can find more on this link about rooting. under the templateUrl you can specify the file path without extension.
UPDATE: You want to use that specific this.$router.config? I'm asking this because you can you something like:
And you won't need to use components, is same thing, i think, for rooting but you will need to add 'ui.router' as a dependency to your app.