AngularJS, UI-Router, Components, TypeScript

1k Views Asked by At

i've tried to create a simple angular1 component with the ui-router but it seems I cannot get it to render and I have 0 error in console...

Here is the code:

Config.ts

module app {
    export class Config {
        constructor(
            $stateProvider: angular.ui.IStateProvider,
            $urlRouterProvider: angular.ui.IUrlRouterProvider,
            $locationProvider: angular.ILocationProvider) {

            $stateProvider.state('home', {
                url: '/Home',
                component: 'home'
            });

            $urlRouterProvider.otherwise('/home');
            $locationProvider.html5Mode(true);
        }
    }

    Config.$inject = ['$stateProvider', '$urlRouterProvider', '$locationProvider'];
}

app.ts

module app {
    var moduleDependencies = [
        'ui.router'
    ];

    angular.module('app', moduleDependencies)
        .config(app.Config)
        .component('home', app.component.home.HomeComponent); // is it required?
}

home.component.ts

module app.component.home {
    class HomeController {

    }

    export class HomeComponent implements angular.IComponentOptions {
        public controller: any;
        public templateUrl: string;

        constructor() {
            this.controller = HomeController;
            this.templateUrl = 'app/main/components/home/home.html';
        };
    }
}

home.html

<div>test</div>

So what am i doing wrong to use my homecomponent ?

0

There are 0 best solutions below