Search code examples
angularjsangular-ui-routerangularjs-componentsstackblitz

Stackblitz not reaching component's scope in AngularJS


I'm trying to use Stackblitz with AngularJS, however the purposed old sintax of routing controller and view is kind of obsolete, so I'm modifying the base example to use ui-router and AngularJS 1.5 Components

<h1>Hello {{$ctrl.name}}!</h1>

The problem I'm having is that seems that Stackblitz is not attaching properly the $ctrl or $scope into the component's template, but it's injecting the template properly.

(I tried to add the component's tag and bindings and pass values <home name="AngularJS"> and seems to work but the problem I have is with the routing)

Here is the example code


Solution

  • I've updated the home.js and it works. Check it please. Is it what you need?

    import template from './home.html';
    import ctrl from './home.controller.js';
    
    let module = angular.module('home', [])
      .component('home', {
    
        // this line
        controller: ctrl,
    
        template
      })
      .name;
    
      export default module;