Stackblitz not reaching component's scope in AngularJS

Issue

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;

Answered By – Max Martynov

Answer Checked By – Dawn Plyler (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.