组件不以角度工作,也不显示任何错误

时间:2017-12-28 08:03:05

标签: javascript angularjs angular-components

无法使用组件呈现html文件。它没有显示任何错误,也没有调用组件内的控制器。



(function(angular) {
  'use strict';
  angular.module('graphApp', []).component('graphDetail', {
    templateUrl: './graphDetail.html',
    controller: function() {
      console.log('I am in component');
    },
    bindings: {
      options: '='
    }
  });
})(window.angular);




1 个答案:

答案 0 :(得分:0)

在这个DEMO中工作正常:

(function(angular) {
  'use strict';
  angular.module('graphApp', []).component('graphDetail', {
    template: `<fieldset>graph-detail</fieldset>`,
    controller: function() {
      console.log('I am in component');
    },
    bindings: {
      options: '='
    }
  });
})(window.angular);
<script src="//unpkg.com/angular/angular.js"></script>
<div ng-app="graphApp">
  <graph-detail options></graph-detail>
</div>