Stackblitz未达到AngularJS中组件的范围

时间:2018-07-26 20:37:28

标签: angularjs angular-ui-router angularjs-components stackblitz

我正在尝试将Stackblitz与AngularJS一起使用,但是路由controllerview的有目的的旧的sintax已经过时了,因此我修改了基本示例以使用ui-routerAngularJS 1.5 Components

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

我遇到的问题是,Stackblitz不能正确地将$ctrl$scope附加到组件的模板中,但却正确地注入了模板。

(我试图添加组件的标签和绑定并传递值<home name="AngularJS">,并且似乎可以正常工作,但是我遇到的问题是布线问题)

Here is the example code

1 个答案:

答案 0 :(得分:1)

我已经更新了home.js,它可以工作了。请检查一下。是您需要的吗?

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;