Converted AngularJS 1.3 directive to 1.5 Component Fails Silently

109 views Asked by At

I'm converting an Angular 1.3 project built in .net to 1.5 components with typescript.

I have a directive that I have boiled down to its simplest possible form. The directive looks like this:

app.directive('myDoctor', function() {
    return {
        template: "Hello World",
        controller: function () {console.log("test");}
    }
});

When I convert it to a component, it looks like this:

app.component('myDoctor', {
    template: "Hello World",
    controller: function () {console.log("test");}
});

The component fails silently in the actual .Net project. Nothing renders, not the template and not the console.log statement. This is in the same ts file, so I know it's not a tsc issue or a bundling issue. The file is being loaded. I confirmed with angular.version that it is indeed running Angular 1.5.7 in the project. I don't believe it's an issue with the component code itself as it works in a plunker seen here:

https://plnkr.co/edit/W8cR69O9BWWnTcwK1e0a?p=preview

But in the real project, it just doesn't do anything at all and I'm at a loss at where else to check or edit to get the component to load.

When I check the source on the page, it shows the file being loaded and contains the same code:

app.component("myDoctor", {
    template: "hello world",
    controller: function () {
        console.log("test");
    }
});

Edit for clarity as to where the issue is happening.

0

There are 0 answers